/* ===================================
   Tool: bmi-calculator
   =================================== */


/* 2カラムWrapper */
.bmi-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 1100px;
  margin: 0 auto var(--space-xl);
}

/* カード共通 */
.bmi-card {
  background: var(--bg-primary);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}

.bmi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.bmi-card--input::before {
  background: linear-gradient(90deg, #1aa37a, #2ecc71);
}

.bmi-card--result::before {
  background: linear-gradient(90deg, #f4c542, #f39c12);
}

.bmi-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.bmi-card__icon {
  font-size: 1.2rem;
}

.bmi-card__title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.bmi-card__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 日本人平均比較バッジ */
.bmi-japan-compare {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.compare-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.compare-value {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: #e8e8e8;
}

.compare-value.compare-average {
  background: #d4edda;
  color: #155724;
}

.compare-value.compare-lower {
  background: #cce5ff;
  color: #004085;
}

.compare-value.compare-higher {
  background: #fff3cd;
  color: #856404;
}

/* スライダー入力グループ */
.bmi-slider-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bmi-slider-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.bmi-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bmi-range {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg, #e0e0e0, #d0d0d0);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.bmi-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #1aa37a, #0f9d8a);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(26, 163, 122, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.bmi-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(26, 163, 122, 0.5);
}

.bmi-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #1aa37a, #0f9d8a);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.bmi-value-input {
  width: 80px;
  padding: 10px 8px;
  background: var(--bg-primary);
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1aa37a;
  text-align: center;
  transition: border-color 0.2s;
}

.bmi-value-input:focus {
  outline: none;
  border-color: #1aa37a;
}

/* コンパクト入力（性別・年齢） */
.bmi-compact-inputs {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.bmi-gender-toggle {
  display: flex;
  gap: 6px;
}

.bmi-gender-btn {
  padding: 10px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  background: var(--bg-primary);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.bmi-gender-btn:hover {
  border-color: #1aa37a;
}

.bmi-gender-btn.active {
  background: linear-gradient(135deg, #1aa37a, #0f9d8a);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(26, 163, 122, 0.3);
}

.bmi-age-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bmi-age-input label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.bmi-age-input input {
  width: 60px;
  padding: 8px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  text-align: center;
}

.bmi-age-input span {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 記録ボタン */
.bmi-record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 56px;
  background: linear-gradient(135deg, #1aa37a, #0f9d8a);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 157, 138, 0.35);
  transition: all 0.2s;
  margin-top: 8px;
}

.bmi-record-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 157, 138, 0.45);
}

.bmi-record-btn:active {
  transform: translateY(0);
}

.bmi-record-btn__icon {
  font-size: 1.1rem;
}

/* シェアボタン */
.bmi-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  background: var(--bg-primary);
  color: #1aa37a;
  font-size: 0.9rem;
  font-weight: 500;
  border: 2px solid #1aa37a;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
}

.bmi-share-btn:hover {
  background: #1aa37a;
  color: white;
}

/* BMIゲージ（改良版） */
.bmi-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}

.bmi-gauge-svg {
  width: 220px;
  height: 130px;
}

.gauge-label-text {
  font-size: 10px;
  fill: #888;
  text-anchor: middle;
}

.gauge-needle-group {
  transition: transform 0.5s ease-out;
}

.bmi-gauge-value {
  text-align: center;
  margin-top: -15px;
}

.bmi-gauge-number {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  transition: color 0.3s;
}

.bmi-gauge-number.bmi-color--low { color: #3498db; }
.bmi-gauge-number.bmi-color--normal { color: #27ae60; }
.bmi-gauge-number.bmi-color--high { color: #e67e22; }
.bmi-gauge-number.bmi-color--danger { color: #e74c3c; }

.bmi-gauge-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* 健康スコアリング */
.bmi-health-score {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f8f9fa, #fff);
  border-radius: 16px;
  border: 1px solid #e8e8e8;
}

.health-score-ring {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.health-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.health-score-ring circle {
  transition: stroke-dashoffset 0.8s ease-out, stroke 0.3s;
}

.health-score-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.health-score-value span {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.health-score-value small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.health-score-info {
  flex: 1;
}

.health-score-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.health-score-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* 体型シルエット */
.bmi-silhouette-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 12px;
}

.silhouette-container {
  width: 60px;
  height: 100px;
}

.body-silhouette {
  width: 100%;
  height: 100%;
}

.silhouette-label {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* 目標体重リスト */
.bmi-targets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bmi-target-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  transition: background 0.2s;
}

.bmi-target-row:hover {
  background: #f8f9fa;
}

.bmi-target-row--highlight {
  background: linear-gradient(135deg, #fff0f3, #ffe8ec);
}

.bmi-target-row--highlight:hover {
  background: linear-gradient(135deg, #ffe8ec, #ffd6dd);
}

.bmi-target-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.bmi-target-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.bmi-target-name small {
  font-weight: 400;
  color: var(--text-muted);
}

.bmi-target-weight {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  min-width: 70px;
  text-align: right;
}

.bmi-target-badge {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  color: #1565c0;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.bmi-target-badge--achieved {
  background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
  color: #2e7d32;
}

.bmi-target-badge--over {
  background: #e8e8e8;
  color: #666;
}

/* アドバイスボックス */
.bmi-advice-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, #f5f7fa, #f0f2f5);
  border-radius: 14px;
  padding: 16px;
  margin-top: 8px;
  border-left: 4px solid #1aa37a;
}

.bmi-advice-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.bmi-advice-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* セクション共通ヘッダー */
.bmi-section-header {
  margin-bottom: 20px;
}

.bmi-section-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* 目標達成シミュレーター */
.bmi-simulator-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.bmi-simulator-content {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
}

.simulator-inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.simulator-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.simulator-input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.simulator-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.simulator-input-wrap input {
  width: 100px;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

.simulator-input-wrap input:focus {
  outline: none;
  border-color: #1aa37a;
}

.simulator-input-group select {
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--bg-primary);
}

.simulator-results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.simulator-result-card {
  background: linear-gradient(135deg, #f8f9fa, #fff);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  border: 1px solid #e8e8e8;
}

.simulator-result-card .result-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.simulator-result-card .result-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.simulator-result-card .result-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1aa37a;
}

/* 詳細データセクション */
.bmi-details-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.bmi-details-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.bmi-detail-card {
  background: linear-gradient(135deg, #f8f9fa, #fff);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  border: 1px solid #e8e8e8;
  transition: transform 0.2s, box-shadow 0.2s;
}

.bmi-detail-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.bmi-detail-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.bmi-detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.bmi-detail-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1aa37a;
}

.bmi-detail-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 栄養素セクション */
.bmi-nutrition-section {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.bmi-nutrition-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 16px 0;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.nutrition-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nutrition-icon {
  font-size: 1.3rem;
}

.nutrition-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nutrition-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.nutrition-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1aa37a;
}

.nutrition-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.nutrition-bar-fill {
  height: 100%;
  border-radius: 3px;
  width: 70%;
}

.water-bar { background: linear-gradient(90deg, #3498db, #2980b9); }
.protein-bar { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.carb-bar { background: linear-gradient(90deg, #f39c12, #e67e22); }
.fat-bar { background: linear-gradient(90deg, #9b59b6, #8e44ad); }

/* 理想体重計算式比較 */
.bmi-formulas-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.formulas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.formula-card {
  background: linear-gradient(135deg, #f0f4f8, #fff);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
}

.formula-card:hover {
  transform: translateY(-2px);
}

.formula-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.formula-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.formula-weight {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1aa37a;
}

/* 達成バッジセクション */
.bmi-badges-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.badge-card {
  background: var(--bg-primary);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  border: 2px solid #e0e0e0;
  position: relative;
  transition: all 0.2s;
}

.badge-card.badge-earned {
  border-color: #f4c542;
  background: linear-gradient(135deg, #fffbeb, #fff);
}

.badge-card.badge-locked {
  opacity: 0.6;
}

.badge-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.badge-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.badge-date {
  font-size: 0.7rem;
  color: #27ae60;
  font-weight: 500;
}

.badge-locked-icon {
  font-size: 1rem;
  opacity: 0.5;
}

/* 履歴セクション */
.bmi-history-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

.bmi-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.bmi-history-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

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

.bmi-history-chart {
  height: 250px;
  margin-bottom: 20px;
}

.bmi-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bmi-history-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.bmi-history-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #f8f9fa, #fff);
  border-radius: 12px;
  border: 1px solid #e8e8e8;
  transition: transform 0.2s;
}

.bmi-history-item:hover {
  transform: translateX(4px);
}

.bmi-history-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 90px;
}

.bmi-history-weight {
  font-weight: 600;
  min-width: 70px;
}

.bmi-history-bmi {
  color: var(--text-secondary);
  flex: 1;
}

.bmi-history-score {
  font-size: 0.85rem;
  color: #f39c12;
  font-weight: 500;
}

/* BMI分類表 */
.bmi-classification-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.classification-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-card);
}

.classification-row.classification-header {
  font-weight: 600;
  background: var(--bg-secondary);
}

.classification-row.underweight { border-left: 4px solid #3498db; }
.classification-row.normal { border-left: 4px solid #27ae60; }
.classification-row.overweight { border-left: 4px solid #f39c12; }
.classification-row.obese1 { border-left: 4px solid #e67e22; }
.classification-row.obese2 { border-left: 4px solid #e74c3c; }

/* コンフェッティキャンバス */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* レスポンシブ */
@media (max-width: 900px) {
  .bmi-simulator-content {
    grid-template-columns: 1fr;
  }

  .simulator-results {
    grid-template-columns: repeat(4, 1fr);
  }

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

@media (max-width: 800px) {
  .bmi-wrapper {
    grid-template-columns: 1fr;
  }

  .bmi-details-grid,
  .nutrition-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 500px) {
  .bmi-card {
    padding: 20px;
  }

  .bmi-compact-inputs {
    flex-direction: column;
    align-items: stretch;
  }

  .bmi-gender-toggle {
    justify-content: center;
  }

  .bmi-age-input {
    justify-content: center;
  }

  .bmi-health-score {
    flex-direction: column;
    text-align: center;
  }

  .bmi-details-grid,
  .nutrition-grid,
  .formulas-grid,
  .badges-grid,
  .simulator-results {
    grid-template-columns: 1fr 1fr;
  }

  .classification-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .classification-row span:first-child {
    font-weight: 600;
  }

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

/* 免責事項 */
.disclaimer-section {
  max-width: 900px;
  margin: var(--space-xl) auto;
  padding: 0 var(--space-md);
}

.disclaimer-box {
  background: var(--bg-secondary);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

.disclaimer-box h3 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.disclaimer-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-sm);
}

.disclaimer-box p:last-child {
  margin-bottom: 0;
}

