/* ============================================
   子其减脂热量计算器 - 主样式表
   ============================================ */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* 科技蓝主色调 */
  --primary: #1a73e8;
  --primary-light: #4a9af5;
  --primary-dark: #0d47a1;
  --primary-bg: rgba(26, 115, 232, 0.08);
  --primary-border: rgba(26, 115, 232, 0.25);

  /* 中性色 */
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* 语义色 */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(26, 115, 232, 0.15);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial,
    sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 容器 */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 40px;
  min-height: 100vh;
}

/* ============ Header ============ */
.app-header {
  text-align: center;
  padding: 40px 0 24px;
}

.app-header .logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(26, 115, 232, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.app-header .logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.app-header .subtitle {
  font-size: 14px;
  color: var(--gray-500);
  font-weight: 400;
}

/* ============ Card ============ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

/* ============ Form ============ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-label .optional {
  color: var(--gray-400);
  font-weight: 400;
  font-size: 12px;
  margin-left: 2px;
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--gray-800);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input.error {
  border-color: var(--danger);
  background: #fef2f2;
}

.form-input::placeholder {
  color: var(--gray-400);
  font-size: 14px;
}

.form-unit {
  display: flex;
  align-items: center;
  position: relative;
}

.form-unit .unit {
  position: absolute;
  right: 14px;
  font-size: 13px;
  color: var(--gray-400);
  pointer-events: none;
}

.form-unit .form-input {
  padding-right: 44px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  min-height: 18px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-item {
  position: relative;
}

.radio-item input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-item label {
  display: inline-block;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.radio-item input:checked + label {
  color: var(--primary);
  background: var(--primary-bg);
  border-color: var(--primary-border);
}

.radio-item label:hover {
  border-color: var(--primary-light);
}

/* ============ Buttons ============ */
.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  height: 48px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* ============ Results ============ */
.results-section {
  display: none;
  animation: fadeInUp 0.4s ease;
}

.results-section.visible {
  display: block;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 结果摘要卡片 */
.result-summary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.result-summary::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.result-summary::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.result-summary .summary-title {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.result-summary .summary-value {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.result-summary .summary-unit {
  font-size: 16px;
  font-weight: 400;
  opacity: 0.7;
}

.result-summary .summary-sub {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  z-index: 1;
}

.result-summary .summary-sub-item {
  display: flex;
  flex-direction: column;
}

.result-summary .summary-sub-item .label {
  font-size: 12px;
  opacity: 0.7;
}

.result-summary .summary-sub-item .value {
  font-size: 20px;
  font-weight: 600;
}

/* 结果详情网格 */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-item {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--gray-100);
  transition: all 0.2s;
}

.result-item:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

.result-item.full {
  grid-column: 1 / -1;
}

.result-item .result-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.result-item .result-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.result-item .result-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.result-item .result-value .unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-500);
  margin-left: 2px;
}

.result-item .result-range {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.result-item .result-range .dash {
  color: var(--gray-400);
  margin: 0 2px;
}

.result-item .result-range .unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-500);
  margin-left: 2px;
}

/* 训练建议卡片 */
.training-card {
  margin-top: 12px;
}

.training-list {
  list-style: none;
}

.training-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.5;
}

.training-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.training-list li .training-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 建议文案卡片 */
.advice-card {
  border-left: 3px solid var(--primary);
}

.advice-card .card-title {
  color: var(--primary);
}

.advice-list {
  list-style: none;
}

.advice-list li {
  padding: 10px 12px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.advice-list li:last-child {
  margin-bottom: 0;
}

.advice-list li .advice-icon {
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 1px;
}

/* ============ Diet Card ============ */
.diet-card {
  margin-top: 16px;
}
.diet-highlight {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.diet-highlight .dh-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--gray-100);
  border-radius: 10px;
}
.diet-highlight .dh-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.diet-highlight .dh-val small {
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-500);
}
.diet-highlight .dh-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}
.meal-section {
  margin-top: 12px;
}
.meal-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.meal-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  align-items: flex-start;
}
.meal-row:last-child {
  border-bottom: none;
}
.meal-label {
  flex-shrink: 0;
  width: 72px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  padding: 3px 8px;
  background: rgba(79,70,229,0.08);
  border-radius: 6px;
  text-align: center;
}
.meal-content {
  flex: 1;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.meal-content small {
  color: var(--gray-500);
  font-size: 11px;
}
.diet-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(245,158,11,0.06);
  border-left: 3px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.diet-note strong {
  color: #d97706;
}
.macro-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0 4px;
  background: var(--gray-200);
}
.macro-bar .mb-protein { background: #3b82f6; }
.macro-bar .mb-carb { background: #f59e0b; }
.macro-bar .mb-fat { background: #ef4444; }
.macro-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 14px;
}
.macro-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.macro-legend .ml-protein::before { background: #3b82f6; }
.macro-legend .ml-carb::before { background: #f59e0b; }
.macro-legend .ml-fat::before { background: #ef4444; }
@media (max-width: 640px) {
  .diet-highlight {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 分享操作栏 */
.share-bar {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.share-bar .btn {
  flex: 1;
  height: 44px;
  font-size: 14px;
}

/* ============ Disclaimer ============ */
.disclaimer {
  margin-top: 32px;
  padding: 16px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.7;
  text-align: center;
}

/* ============ Calculator → Training CTA ============ */
.calc-to-training {
  margin: 20px 0 8px;
}
.calc-to-training-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 50%, #2563eb 100%);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(79,70,229,.35);
  transition: all .3s;
}
.calc-to-training-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(79,70,229,.5);
}
.calc-to-training-icon {
  font-size: 40px;
  flex-shrink: 0;
}
.calc-to-training-text {
  flex: 1;
}

/* 目标体重建议 */
.target-weight-hint {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
}
.twh-range {
  color: #6b7280;
  padding: 6px 10px;
  background: #f0fdf4;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  margin-bottom: 6px;
}
.twh-range b {
  color: #16a34a;
}
.twh-suggest {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.twh-btn {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #c4b5fd;
  background: #f5f3ff;
  color: #7c3aed;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.twh-btn:hover {
  background: #7c3aed;
  color: #fff;
}
.twh-warn {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  padding: 4px 8px;
  background: #fef2f2;
  border-radius: 4px;
  display: none;
}
.calc-to-training-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.calc-to-training-desc {
  font-size: 13px;
  color: rgba(255,255,255,.8);
}
.calc-to-training-btn {
  flex-shrink: 0;
  padding: 12px 28px;
  background: #fff;
  color: #4f46e5;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.calc-to-training-btn:hover {
  background: #f0f0ff;
  transform: scale(1.05);
}

/* ============ Formula Reference Section ============ */
.formula-ref-section {
  margin-top: 32px;
}
.formula-ref-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}
.formula-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  margin-bottom: 16px;
}
.formula-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.formula-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.formula-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}
.formula-card-body {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.8;
}
.formula-method-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--gray-100);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.formula-code {
  display: block;
  background: #f8fafc;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 8px 14px;
  margin: 6px 0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: #334155;
  overflow-x: auto;
  white-space: nowrap;
}
.formula-desc {
  margin: 8px 0;
  color: var(--gray-600);
}
.formula-source {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--gray-400);
  font-style: italic;
}
.formula-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
}
.formula-table th {
  background: var(--gray-100);
  font-weight: 600;
  text-align: left;
  padding: 6px 12px;
  border-bottom: 2px solid var(--gray-300);
  color: var(--gray-700);
}
.formula-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-600);
}
.formula-table tr:last-child td {
  border-bottom: none;
}

/* Body Fat Classification */
.bf-classification {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--gray-300);
}
.bf-class-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 12px;
}
.bf-class-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .bf-class-tables {
    grid-template-columns: 1fr;
  }
}
.bf-class-table-wrap {
  min-width: 0;
}
.bf-class-table-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  padding: 4px 12px;
  border-radius: 6px 6px 0 0;
  text-align: center;
}
.bf-class-table-wrap:nth-child(2) .bf-class-table-label {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}
.bf-table th {
  border-radius: 0;
}
.bf-table .bf-essential td { color: #dc2626; font-weight: 600; }
.bf-table .bf-athlete td { color: #f59e0b; font-weight: 600; }
.bf-table .bf-fit td { color: #16a34a; font-weight: 600; }
.bf-table .bf-average td { color: #2563eb; }
.bf-table .bf-obese td { color: #9333ea; font-weight: 600; }

/* ============ Platform Philosophy ============ */
.platform-philosophy {
  margin-top: 40px;
  padding: 32px 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  border-radius: 16px;
  text-align: center;
}
.philosophy-main { margin-bottom: 28px; }
.philosophy-tagline {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #60a5fa;
  margin-bottom: 12px;
  font-style: italic;
}
.philosophy-subtitle {
  font-size: 16px;
  color: #e2e8f0;
  margin-bottom: 10px;
  font-weight: 500;
}
.philosophy-keyword {
  color: #93c5fd;
  font-weight: 600;
}
.philosophy-desc {
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.8;
}
.philosophy-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.philosophy-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px 10px 16px;
  text-align: center;
  transition: all 0.25s ease;
}
.philosophy-card:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(96,165,250,0.4);
  transform: translateY(-2px);
}
.philosophy-card-icon {
  color: #60a5fa;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}
.philosophy-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 6px;
}
.philosophy-card-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.5;
}
@media (max-width: 768px) {
  .philosophy-cards { grid-template-columns: repeat(3, 1fr); }
  .philosophy-tagline { font-size: 18px; }
  .philosophy-subtitle { font-size: 14px; }
}
@media (max-width: 480px) {
  .philosophy-cards { grid-template-columns: repeat(2, 1fr); }
  .platform-philosophy { padding: 24px 16px; }
  .philosophy-tagline { font-size: 16px; }
}


/* ============ Responsive ============ */
@media (max-width: 480px) {
  .app-container {
    padding: 0 12px 32px;
  }

  .app-header {
    padding: 32px 0 20px;
  }

  .app-header h1 {
    font-size: 22px;
  }

  .card {
    padding: 20px 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .result-item .result-value {
    font-size: 18px;
  }

  .result-summary .summary-value {
    font-size: 36px;
  }

  .result-summary .summary-sub-item .value {
    font-size: 18px;
  }

  .radio-group {
    gap: 6px;
  }

  .radio-item label {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (min-width: 768px) {
  .app-container {
    padding: 0 24px 60px;
  }

  .app-header h1 {
    font-size: 30px;
  }
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

/* ============ Scroll to top ============ */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 100;
  transition: all 0.2s;
}

.scroll-top-btn.visible {
  display: flex;
}

.scroll-top-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============ Poster Modal ============ */
.poster-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.poster-overlay.visible {
  display: flex;
}

.poster-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeInUp 0.3s ease;
}

@media (max-width: 480px) {
  .poster-overlay {
    padding: 10px;
    align-items: flex-end;
  }

  .poster-content {
    max-width: 100%;
    padding: 20px 16px;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }

  .poster-text {
    max-height: 200px;
    font-size: 12px;
  }
}

.poster-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
  text-align: center;
}

.poster-text {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.poster-actions {
  display: flex;
  gap: 12px;
}

.poster-actions .btn {
  flex: 1;
  height: 42px;
  font-size: 14px;
}

/* ============ Back Link (Calculator Page) ============ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 16px;
  padding: 4px 0;
  transition: opacity 0.2s;
}

.back-link:hover {
  opacity: 0.75;
}

.back-link svg {
  margin-top: -1px;
}

/* ============ Homepage ============ */
.home-header {
  text-align: center;
  padding: 56px 0 32px;
  position: relative;
}

.home-user-bar {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  z-index: 10;
}

.home-user-bar a {
  transition: color 0.2s;
}

.home-user-bar a:hover {
  color: #1d4ed8 !important;
}

.home-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(26, 115, 232, 0.25), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.home-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  white-space: nowrap;
}

.home-subtitle {
  font-size: 14px;
  color: var(--gray-500);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .tool-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--gray-100);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.tool-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tool-card:active {
  transform: translateY(0);
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-bg), rgba(26, 115, 232, 0.15));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-card-body {
  flex: 1;
  min-width: 0;
}

.tool-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-card-arrow {
  color: var(--gray-400);
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

.tool-card:hover .tool-card-arrow {
  color: var(--primary);
  transform: translateX(2px);
}

.home-footer {
  text-align: center;
  margin-top: 48px;
  padding-bottom: 24px;
}

.home-footer p {
  font-size: 13px;
  color: var(--gray-400);
}

/* Homepage responsive */
@media (max-width: 480px) {
  .home-header {
    padding: 40px 0 24px;
  }

  .home-user-bar {
    top: 10px;
    right: 12px;
    font-size: 12px;
    gap: 8px;
  }

  .home-title {
    font-size: 24px;
  }

  .tool-card {
    padding: 16px;
    gap: 12px;
  }

  .tool-card-icon {
    width: 44px;
    height: 44px;
  }

  .tool-card-icon svg {
    width: 24px;
    height: 24px;
  }

  .tool-card-name {
    font-size: 15px;
  }

  .tool-card-desc {
    font-size: 12px;
  }
}

/* ============ Tool Card Tags ============ */
.tool-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.tool-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-bg);
  border-radius: 4px;
  white-space: nowrap;
}

/* ============ Section Label ============ */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  margin-top: 28px;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.section-label:first-of-type {
  margin-top: 0;
}

.section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.section-dot-muted {
  background: var(--gray-300);
}

/* ============ Disabled Tool Card ============ */
.tool-card-disabled {
  cursor: default;
  opacity: 0.65;
  border-style: dashed;
}

.tool-card-disabled:hover {
  border-color: var(--gray-200);
  box-shadow: var(--shadow-sm);
  transform: none;
}

.tool-card-icon-disabled {
  background: var(--gray-100);
  color: var(--gray-400);
}

.badge-soon {
  display: inline-block;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-100);
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 8px;
  letter-spacing: 0.03em;
  line-height: 18px;
}

/* ============ Highlights ============ */
.highlights {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}

.highlight-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.highlight-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.highlight-text {
  flex: 1;
  min-width: 0;
}

.highlight-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.highlight-desc {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* Highlights responsive */
@media (max-width: 480px) {
  .highlight-icon {
    width: 36px;
    height: 36px;
  }

  .highlight-icon svg {
    width: 18px;
    height: 18px;
  }

  .highlight-title {
    font-size: 13px;
  }

  .highlight-desc {
    font-size: 12px;
  }

  .home-logo {
    width: 72px;
    height: 72px;
  }
}

/* ===== 导航栏 ===== */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gray-100);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transition: background 0.3s, border-color 0.3s;
}

/* 导航栏占位，防止内容被fixed遮挡 */
.nav-bar-spacer {
  height: 52px;
}

/* 返回顶部按钮 */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 80px;
  z-index: 999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.35);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  pointer-events: none;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--primary-dark, #1557b0);
  transform: translateY(-2px);
}
.back-to-top svg {
  width: 20px;
  height: 20px;
}
.nav-bar.theme-dark {
  background: rgba(10, 14, 26, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.nav-bar.theme-light {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--gray-100);
}

.nav-bar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.theme-dark .nav-bar-brand {
  color: #e2e8f0;
}
.nav-bar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.nav-bar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.theme-dark .nav-bar-hamburger {
  color: #e2e8f0;
}
.nav-bar-hamburger:hover {
  background: var(--gray-100);
}
.theme-dark .nav-bar-hamburger:hover {
  background: rgba(255,255,255,0.1);
}
.nav-bar-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}
.nav-bar-links {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--gray-200);
}
.theme-dark .nav-bar-right {
  border-left-color: rgba(255,255,255,0.1);
}

.nav-bar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-bar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.nav-bar-link {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  cursor: pointer;
  white-space: nowrap;
}

.nav-bar-link:hover {
  background: var(--primary-bg);
}

.nav-bar-link.active {
  background: var(--primary-bg);
  font-weight: 600;
}

.nav-bar-link.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
}

.nav-bar-link.btn-primary:hover {
  background: var(--primary-dark, #1a56db);
}

.nav-bar-link.btn-ghost {
  color: var(--text-secondary);
}

.nav-bar-link.btn-ghost:hover {
  background: var(--gray-50);
  color: var(--text-primary);
}

/* ===== 导航栏深色主题 ===== */
.nav-bar--dark {
  background: rgba(10, 14, 26, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.nav-bar--dark .nav-bar-brand {
  color: #e2e8f0;
}
.nav-bar--dark .nav-bar-hamburger {
  color: #94a3b8;
}
.nav-bar--dark .nav-bar-hamburger:hover {
  background: rgba(255, 255, 255, 0.08);
}
.nav-bar--dark .nav-bar-link {
  color: #94a3b8;
}
.nav-bar--dark .nav-bar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}
.nav-bar--dark .nav-bar-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.nav-bar--dark .nav-bar-link.btn-ghost {
  color: #94a3b8;
}
.nav-bar--dark .nav-bar-link.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}
.nav-bar--dark .nav-bar-link.btn-primary {
  background: #3b82f6;
  color: #fff;
}
.nav-bar--dark .nav-bar-right {
  border-left-color: rgba(255, 255, 255, 0.1);
}
.nav-bar--dark .nav-bar-user {
  color: #94a3b8;
}
.nav-bar--dark .nav-bar-user-avatar {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* ===== 微信小程序/移动端适配 ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .nav-bar {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}

/* 微信小程序内webview适配 */
.wx-embed .nav-bar {
  padding-top: calc(10px + env(safe-area-inset-top));
}
.wx-embed .nav-bar-menu.open {
  max-height: calc(100vh - 60px - env(safe-area-inset-top));
  padding-bottom: env(safe-area-inset-bottom);
}
.wx-embed .page-content,
.wx-embed main,
.wx-embed .s-wrap {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/* ===== 微信小程序环境适配 ===== */
.wx-env .nav-bar {
  padding-top: calc(env(safe-area-inset-top) + 8px);
  height: auto;
  min-height: 52px;
}
.wx-env .nav-bar--dark {
  padding-top: calc(env(safe-area-inset-top) + 8px);
}
.wx-env .page-content,
.wx-env main,
.wx-env .s-wrap {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.wx-env body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}
/* 微信内禁止文字选中(避免长按弹菜单) */
.wx-env .nav-bar,
.wx-env .nav-bar a,
.wx-env .nav-bar span {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 微信内触摸优化 */
.wx-env .nav-bar a,
.wx-env .nav-bar .nav-brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.wx-env .nav-bar .nav-links a {
  padding: 8px 10px;
  min-height: 44px;
}

/* ===== 微信小程序 & 移动端通用适配 ===== */

/* 移动端基础：防止横向溢出 */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 移动端触摸友好：最小点击区域 44px */
@media (max-width: 768px) {
  button, a, input, select, textarea, [role="button"] {
    min-height: 44px;
  }
  /* 移动端隐藏hover效果（无鼠标） */
  *:hover {
    /* 仅保留有意义的hover，不改变布局 */
  }
}

/* 微信小程序环境 */
.wx-env, .wx-embed {
  /* 禁止长按弹出菜单 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 允许输入框和特定区域选择文字 */
.wx-env input, .wx-embed input,
.wx-env textarea, .wx-embed textarea,
.wx-env [data-selectable], .wx-embed [data-selectable] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 微信小程序安全区域 */
.wx-env body, .wx-embed body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* 微信小程序底部安全区域 */
.wx-env .page-content, .wx-embed .page-content,
.wx-env main, .wx-embed main,
.wx-env .s-wrap, .wx-embed .s-wrap,
.wx-env .sc-main, .wx-embed .sc-main {
  padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
}

/* 微信小程序导航栏安全区域 */
.wx-env .nav-bar, .wx-embed .nav-bar,
.wx-env .sc-nav, .wx-embed .sc-nav {
  padding-top: calc(env(safe-area-inset-top) + 8px) !important;
}

/* 移动端：表格横向滚动 */
@media (max-width: 768px) {
  /* 表格容器可横向滚动 */
  .table-wrap, .sc-table-wrap, [data-table-scroll] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 移动端网格改为单列 */
  .grid-2, .grid-3, .grid-4,
  [data-cols="2"], [data-cols="3"], [data-cols="4"] {
    grid-template-columns: 1fr !important;
  }
  /* 移动端固定宽度元素约束 */
  [style*="width:8"], [style*="width: 8"],
  [style*="width:9"], [style*="width: 9"],
  [style*="width:10"], [style*="width: 10"],
  [style*="width:11"], [style*="width: 11"],
  [style*="width:12"], [style*="width: 12"] {
    max-width: 100% !important;
    width: 100% !important;
  }
  /* 移动端容器最大宽度 */
  .container, .page-content, main, .s-wrap {
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  /* 移动端输入框宽度 */
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], input[type="search"], input[type="tel"],
  select, textarea {
    max-width: 100% !important;
  }
}

/* 微信小程序 & 超小屏(< 400px) 专用适配 */
@media (max-width: 400px) {
  /* 所有结果网格强制单列 */
  .result-grid {
    grid-template-columns: 1fr !important;
  }
  /* 卡片内边距缩小 */
  .card, .result-item, .tool-card {
    padding: 12px !important;
  }
  /* 标题字号缩小 */
  .app-header h1, h1 {
    font-size: 18px !important;
  }
  /* 按钮最小高度保证可点击 */
  button, .btn, [role="button"], a.btn {
    min-height: 44px;
    min-width: 44px;
  }
  /* 表单行间距 */
  .form-row, .form-group {
    margin-bottom: 12px !important;
  }
  /* pill/radio 选择器缩小 */
  .pill-group, .radio-group {
    gap: 4px !important;
  }
  .pill-group label, .radio-group label {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
}

/* 微信小程序内图片适配 */
.wx-env img, .wx-embed img {
  max-width: 100%;
  height: auto;
}

/* 微信小程序内禁用页面弹性滚动 */
.wx-env html, .wx-embed html {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.wx-env body, .wx-embed body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== 登录/注册页面 ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 36px 28px;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: block;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-100);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-field {
  margin-bottom: 16px;
  text-align: left;
}

.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.2s;
  box-sizing: border-box;
  outline: none;
}

.auth-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  display: none;
}

.auth-error.visible {
  display: block;
}

.auth-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.auth-btn:hover {
  background: var(--primary-dark, #1a56db);
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-link {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-link a {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* ===== 历史记录页面 ===== */
.history-page {
  min-height: 100vh;
  background: var(--bg);
}

.history-header {
  text-align: center;
  padding: 32px 20px 16px;
}

.history-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.history-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.history-empty svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.history-empty p {
  font-size: 14px;
}

.history-list {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.history-card {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 20px;
  margin-bottom: 14px;
  position: relative;
  transition: box-shadow 0.2s;
}

.history-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.history-card-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-card-delete {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
}

.history-card-delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

.history-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.history-card-item {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.history-card-item-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.history-card-item-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-card-item-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.history-card-inputs {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-input-tag {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 10px;
}

/* ============ 全局移动端适配 ============ */

/* 导航栏移动端 */
@media (max-width: 768px) {
  .nav-bar {
    padding: 8px 12px;
    flex-wrap: nowrap;
    position: relative;
  }

  .nav-bar-brand span {
    display: none;
  }

  .nav-bar-hamburger {
    display: flex;
  }

  .nav-bar-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-direction: column;
    padding: 8px 12px;
    gap: 0;
    z-index: 200;
  }

  .nav-bar-menu.open {
    display: flex;
  }

  .nav-bar-links {
    flex-direction: column;
    gap: 0;
    width: 100%;
  }

  .nav-bar-right {
    flex-direction: column;
    border-left: none;
    margin-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--gray-100);
    padding-top: 8px;
    margin-top: 4px;
    gap: 0;
    width: 100%;
  }

  .nav-bar-link {
    padding: 10px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    width: 100%;
    display: block;
  }

  .nav-bar-user span {
    display: inline;
  }

  .nav-bar-user {
    padding: 8px 12px;
  }
}

/* 极小屏幕（≤380px） */
@media (max-width: 380px) {
  .nav-bar-link {
    font-size: 13px;
  }

  .nav-bar-user-avatar {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .home-title {
    font-size: 18px;
  }
}

/* 主页移动端 */
@media (max-width: 640px) {
  .home-header {
    padding: 32px 0 20px;
  }

  .home-logo {
    width: 64px;
    height: 64px;
  }

  .home-title {
    font-size: 22px;
  }

  .home-subtitle {
    font-size: 13px;
  }

  .highlight-item {
    padding: 12px 0;
    gap: 10px;
  }

  .highlight-icon {
    width: 34px;
    height: 34px;
  }

  .highlight-title {
    font-size: 13px;
  }

  .highlight-desc {
    font-size: 12px;
  }

  .tool-card-tags {
    gap: 3px;
  }

  .tool-tag {
    font-size: 10px;
    padding: 1px 6px;
  }

  .section-label {
    font-size: 12px;
    margin-top: 20px;
  }
}

/* 计算器页面移动端增强 */
@media (max-width: 480px) {
  .app-container {
    padding: 0 10px 24px;
  }

  .app-header {
    padding: 24px 0 16px;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 13px;
  }

  .logo-icon {
    width: 56px;
    height: 56px;
  }

  .logo-img {
    width: 56px;
    height: 56px;
  }

  .card {
    padding: 16px 12px;
    border-radius: 12px;
  }

  .card-title {
    font-size: 15px;
    margin-bottom: 16px;
  }

  .form-label {
    font-size: 13px;
  }

  .form-input {
    font-size: 15px; /* 防止 iOS 缩放 */
    padding: 10px 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .radio-group {
    gap: 4px;
    flex-wrap: wrap;
  }

  .radio-item {
    flex: 1 1 auto;
    min-width: 0;
  }

  .radio-item label {
    padding: 6px 8px;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .result-item .result-value {
    font-size: 16px;
  }

  .result-item .result-label {
    font-size: 11px;
  }

  .result-summary .summary-value {
    font-size: 32px;
  }

  .result-summary .summary-sub-item .value {
    font-size: 16px;
  }

  .btn {
    height: 44px;
    font-size: 15px;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
  }

  .advice-card {
    padding: 12px;
  }

  .advice-list li {
    font-size: 13px;
  }
}

/* 计算器平板尺寸 */
@media (min-width: 481px) and (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 登录/注册页面移动端 */
@media (max-width: 640px) {
  .auth-card {
    padding: 28px 20px;
  }

  .auth-switch {
    font-size: 12px;
  }
}

/* 历史记录移动端 */
@media (max-width: 640px) {
  .history-card {
    padding: 14px;
    margin-bottom: 10px;
  }

  .history-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .history-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .history-summary-item {
    padding: 8px;
  }

  .history-value {
    font-size: 14px;
  }

  .history-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .history-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .history-tags {
    gap: 4px;
  }
}

/* 历史详情弹窗移动端 */
@media (max-width: 640px) {
  .detail-overlay {
    padding: 10px;
  }

  .detail-content {
    max-width: 100%;
    padding: 16px;
    max-height: 90vh;
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .detail-grid .detail-item {
    padding: 8px;
  }

  .detail-inputs {
    padding: 12px;
  }

  .detail-input-row {
    padding: 4px 0;
    font-size: 12px;
  }
}

/* ===== 登录页切换链接 ===== */
.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ===== 历史记录卡片（补充样式） ===== */
.history-card {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  padding: 18px;
  margin-bottom: 14px;
  transition: box-shadow 0.2s;
}

.history-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.history-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.history-actions {
  display: flex;
  gap: 8px;
}

.history-btn {
  background: none;
  border: 1px solid var(--gray-200);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.history-btn:hover {
  background: var(--gray-50);
  color: var(--text-primary);
}

.history-btn-danger:hover {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 480px) {
  .history-summary {
    grid-template-columns: repeat(4, 1fr);
  }
}

.history-summary-item {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.history-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.history-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* ============================================
   目标体重建议
   ============================================ */
.tw-advice-box {
  margin-top: 8px;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  min-height: 0;
}

.tw-advice-box:empty {
  display: none;
}

.tw-advice-range,
.tw-advice-rec {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--primary-bg, rgba(26, 115, 232, 0.08));
  border: 1px solid var(--primary-border, rgba(26, 115, 232, 0.25));
}

.tw-advice-rec {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  cursor: pointer;
  transition: background 0.2s;
}

.tw-advice-rec:hover {
  background: rgba(16, 185, 129, 0.15);
}

.tw-advice-label {
  color: var(--text-secondary, #64748b);
  font-size: 12px;
}

.tw-advice-value {
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  font-size: 13px;
}

.tw-clickable {
  color: #10b981;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tw-advice-warn {
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
}

.tw-advice-warn.tw-danger {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.tw-advice-warn.tw-caution {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #d97706;
}

.tw-advice-warn.tw-ok {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #059669;
}

.tw-advice-warn.tw-info {
  background: rgba(26, 115, 232, 0.08);
  border: 1px solid rgba(26, 115, 232, 0.3);
  color: #1a73e8;
}

