/* ============================================
   リセット・CSS変数
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --orange:      #FF6B35;
  --orange-pale: #FFF0EA;
  --black:       #1A1A1A;
  --gray-dark:   #2A2A2A;
  --gray:        #888888;
  --gray-light:  #F4F4F4;
  --white:       #FFFFFF;
  --danger:      #FC8181;
  --success:     #48BB78;

  --header-h: 56px;
  --nav-h:    64px;
}

html, body { height: 100%; background: #E8E8E8; }

body {
  font-family: -apple-system, BlinkMacSystemFont,
    'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
  color: var(--black);
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   アプリコンテナ
   ============================================ */
#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow: hidden;
  /* ノッチ左右対応 */
  padding-left:  env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ============================================
   ヘッダー
   ============================================ */
.header {
  background: var(--black);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  /* ノッチ上部対応 */
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-h) + env(safe-area-inset-top));
}

.header-title {
  color: var(--orange);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 2px;
}

.header-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.65;
  padding: 6px;
  line-height: 1;
}

/* ============================================
   メインコンテンツ
   ============================================ */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================
   各画面
   ============================================ */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active { display: flex; }

/* アドバイス画面は内部でスクロール制御 */
#screen-advice { overflow: hidden; }

/* 共通：セクションタイトル */
.section-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gray);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* 共通：空メッセージ */
.empty-msg {
  text-align: center;
  color: var(--gray);
  font-size: 0.85rem;
  padding: 28px 0;
}

/* ============================================
   ホーム画面
   ============================================ */
.home-date {
  text-align: center;
  padding: 18px 20px 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
}

/* カロリーリング */
.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 8px auto 12px;
}

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

.ring-bg {
  fill: none;
  stroke: var(--gray-light);
  stroke-width: 13;
}

.ring-fill {
  fill: none;
  stroke: var(--orange);
  stroke-width: 13;
  stroke-linecap: round;
  /* 2π × 64 ≈ 402 */
  stroke-dasharray: 402;
  stroke-dashoffset: 402;
  transition: stroke-dashoffset 0.7s ease;
}

.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--black);
  line-height: 1;
}

.ring-unit {
  font-size: 0.72rem;
  color: var(--gray);
  margin-top: 3px;
}

.ring-tag {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: 1px;
  margin-top: 5px;
}

/* サマリーカード3枚 */
.home-cards {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.home-card {
  flex: 1;
  background: var(--gray-light);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
}

.home-card.accent { background: var(--orange-pale); }

.home-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
  margin-bottom: 5px;
}

.home-card-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--black);
}

.home-card-value small {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--gray);
  margin-left: 1px;
}

/* 今日の食事セクション */
.home-section {
  padding: 0 16px 32px;
}

.home-meal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-light);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 7px;
  font-size: 0.88rem;
}

.home-meal-name { font-weight: 600; color: var(--black); }
.home-meal-kcal { font-weight: 700; color: var(--orange); }

/* ============================================
   セグメントタブ（食事・グラフ共通）
   ============================================ */
.seg-tabs {
  display: flex;
  background: var(--gray-light);
  margin: 14px 14px 0;
  border-radius: 14px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: 11px;
  background: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.seg-tab.active {
  background: var(--white);
  color: var(--orange);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ============================================
   食事画面
   ============================================ */
.meal-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px 8px;
  flex-shrink: 0;
}

.meal-total-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
}

.meal-total-value {
  font-size: 1rem;
  font-weight: 900;
  color: var(--orange);
}

.meal-list {
  flex: 1;
  padding: 0 14px 96px;
  overflow-y: auto;
}

.meal-item {
  display: flex;
  align-items: center;
  background: var(--gray-light);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  gap: 12px;
}

.meal-item-icon { font-size: 1.5rem; line-height: 1; }

.meal-item-info { flex: 1; }

.meal-item-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--black);
}

.meal-item-kcal {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--orange);
  margin-top: 2px;
}

.meal-item-del {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* FABボタン */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  right: max(16px, calc((100vw - 430px) / 2 + 16px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  font-size: 1.8rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255,107,53,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.fab.visible { display: flex; }
.fab:active  { transform: scale(0.9); }

/* ============================================
   体重画面
   ============================================ */
.weight-card {
  background: var(--black);
  margin: 16px;
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  flex-shrink: 0;
}

.weight-card-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.weight-input-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.weight-input {
  font-size: 3rem;
  font-weight: 900;
  color: var(--white);
  background: none;
  border: none;
  border-bottom: 3px solid var(--orange);
  width: 140px;
  text-align: center;
  outline: none;
  line-height: 1;
}

.weight-input::placeholder { color: rgba(255,255,255,0.2); }

.weight-unit {
  font-size: 1.2rem;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  margin-bottom: 6px;
}

.weight-history {
  padding: 8px 16px 32px;
  overflow-y: auto;
}

.weight-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-light);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 8px;
}

.weight-item-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray);
}

.weight-item-right {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.weight-item-val {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--black);
}

.weight-diff {
  font-size: 0.72rem;
  font-weight: 700;
}

.diff-up   { color: var(--danger); }
.diff-down { color: var(--success); }
.diff-same { color: var(--gray); }

/* ============================================
   グラフ画面
   ============================================ */
/* 期間タブ */
.period-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.period-tabs::-webkit-scrollbar { display: none; }

.period-tab {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid #E0E0E0;
  background: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.period-tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
}

.chart-wrap {
  padding: 12px 10px 4px;
}

.chart-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 18px 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
  display: inline-block;
  flex-shrink: 0;
}

/* グラフ下サマリーカード */
.graph-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 14px 24px;
}

.graph-stat-card {
  background: var(--gray-light);
  border-radius: 14px;
  padding: 12px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.graph-stat-card.accent { background: var(--orange-pale); }

.graph-stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
}

.graph-stat-value {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--black);
  line-height: 1;
}

.graph-stat-unit {
  font-size: 0.6rem;
  color: var(--gray);
  font-weight: 600;
}

/* 目標進捗バー */
.goal-progress-wrap {
  margin: 0 14px 24px;
  background: var(--gray-light);
  border-radius: 16px;
  padding: 14px 16px;
}

.goal-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.goal-progress-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
}

.goal-progress-remain {
  font-size: 1rem;
  font-weight: 900;
  color: var(--orange);
}

.goal-progress-track {
  background: #E0E0E0;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.goal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #FFB347);
  border-radius: 99px;
  transition: width 0.6s ease;
  width: 0%;
}

.goal-progress-sub {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray);
}

/* ============================================
   アドバイス画面
   ============================================ */

/* APIキー設定 */
.apikey-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
  flex: 1;
}

.apikey-setup.hidden { display: none; }

.apikey-icon  { font-size: 3rem; }
.apikey-title { font-size: 1.1rem; font-weight: 800; color: var(--black); }

.apikey-desc {
  font-size: 0.82rem;
  color: var(--gray);
  line-height: 1.65;
}

.apikey-input {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  font-size: 0.85rem;
  font-family: monospace;
  outline: none;
  transition: border-color 0.2s;
}

.apikey-input:focus { border-color: var(--orange); }

/* チャット */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-area.hidden { display: none; }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-bubble.ai {
  background: var(--gray-light);
  color: var(--black);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.chat-bubble.user {
  background: var(--orange);
  color: var(--white);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

.chat-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #F0F0F0;
  background: var(--white);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 13px;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--orange); }

.chat-send {
  padding: 10px 16px;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
}

/* ============================================
   ボトムナビ
   ============================================ */
.bottom-nav {
  display: flex;
  background: var(--black);
  flex-shrink: 0;
  border-top: 2px solid var(--gray-dark);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.nav-item:active { background: rgba(255,107,53,0.1); }

/* アクティブインジケーター（上部ライン） */
.nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--orange);
  border-radius: 0 0 4px 4px;
}

.nav-icon {
  font-size: 1.35rem;
  line-height: 1;
  filter: grayscale(1) brightness(0.5);
  transition: filter 0.2s;
}

.nav-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
  transition: color 0.2s;
}

.nav-item.active .nav-icon  { filter: none; }
.nav-item.active .nav-label { color: var(--orange); }

/* ============================================
   共通ボタン
   ============================================ */
.btn-primary {
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.3px;
  transition: opacity 0.15s;
}

.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: var(--gray-light);
  color: var(--gray);
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}

/* ============================================
   モーダル
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 430px;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 追加ボタンを常に画面下部に固定 */
.modal-btns-sticky {
  position: sticky;
  bottom: 0;
  background: var(--white);
  padding-top: 8px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
  margin-left: -20px;
  margin-right: -20px;
  padding-left: 20px;
  padding-right: 20px;
  border-top: 1px solid var(--light-gray);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--black);
  text-align: center;
  margin-bottom: 4px;
}

.modal-field { display: flex; flex-direction: column; gap: 5px; }

.modal-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray);
  letter-spacing: 0.3px;
}

.modal-input {
  padding: 12px 13px;
  border: 2px solid #E2E8F0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}

.modal-input:focus { border-color: var(--orange); }

.modal-btns { display: flex; gap: 10px; align-items: stretch; }

/* モーダル内ボタンは幅auto（flexで均等割り） */
.modal-btns .btn-secondary { flex: 1; }
.modal-btn-primary { flex: 2; width: auto; }

/* 食品名＋kcal横並び */
.modal-row { display: flex; gap: 10px; align-items: flex-end; }
.modal-row .modal-field { display: flex; flex-direction: column; gap: 5px; }

/* カロリー行（input + AI推定ボタン） */
.modal-kcal-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

/* AI推定ボタン */
.btn-ai-estimate {
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-ai-estimate:active  { opacity: 0.75; }
.btn-ai-estimate:disabled { opacity: 0.4; cursor: not-allowed; }

.ai-btn-icon { font-size: 1.3rem; line-height: 1; }
.ai-btn-text { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.5px; }

/* ============================================
   写真エリア
   ============================================ */
.photo-area {
  position: relative;
  width: 100%;
  height: 80px; /* コンパクトにしてボタンまで届きやすくする */
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.photo-placeholder {
  width: 100%;
  height: 100%;
  background: var(--gray-light);
  border: 2px dashed #D4D4D4;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

.photo-placeholder:hover { background: #ECECEC; }
.photo-ph-icon { font-size: 1.8rem; line-height: 1; }
.photo-ph-text { font-size: 0.75rem; font-weight: 700; color: var(--gray); }

.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 13px;
}

.photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================
   設定モーダル
   ============================================ */
.modal-settings {
  max-height: 92dvh;
  overflow-y: auto;
  gap: 16px;
}

.settings-handle {
  width: 36px;
  height: 4px;
  background: #E0E0E0;
  border-radius: 2px;
  margin: 0 auto -6px;
  flex-shrink: 0;
}

/* 年齢・身長・体重の横並び */
.settings-row {
  display: flex;
  gap: 8px;
}

.settings-row .modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* 単位付きinput */
.input-unit-wrap { position: relative; }

.input-unit-wrap .modal-input { padding-right: 30px; }

.input-unit {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray);
  pointer-events: none;
}

/* 性別トグル */
.gender-toggle {
  display: flex;
  background: var(--gray-light);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.gender-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: none;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.gender-btn.active {
  background: var(--white);
  color: var(--orange);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 目標ボタン（3択） */
.goal-seg {
  display: flex;
  gap: 8px;
}

.goal-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border: 2px solid #E8E8E8;
  border-radius: 14px;
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.goal-btn.active {
  border-color: var(--orange);
  background: var(--orange-pale);
}

.goal-btn-icon { font-size: 1.4rem; line-height: 1; }

.goal-btn-name {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--black);
  text-align: center;
  line-height: 1.2;
}

.goal-btn-sub {
  font-size: 0.62rem;
  color: var(--gray);
  font-weight: 600;
}

/* 計算結果カード */
.calc-card {
  background: var(--black);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calc-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.calc-item { text-align: center; }

.calc-lbl {
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.calc-val {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--white);
  line-height: 1;
}

.calc-sub {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.35);
  margin-top: 3px;
}

.calc-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,0.1);
}

.calc-target-wrap {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
  text-align: center;
}

.calc-target-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.calc-target-val {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--orange);
  line-height: 1;
}

.calc-target-unit {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  margin-left: 4px;
}

/* BMIラベルの色 */
.bmi-thin   { color: #63B3ED; }
.bmi-normal { color: #68D391; }
.bmi-over   { color: #FC8181; }

/* 食事リストのサムネイル */
.meal-item-photo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ============================================
   ① PFCバー（ホーム画面）
   ============================================ */
.pfc-bars {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 各バーの行 */
.pfc-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* バーのヘッダー（ラベル + 数値情報） */
.pfc-bar-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* P/F/Cのラベル */
.pfc-bar-label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  width: 14px;
  text-align: center;
}

/* バー横の情報テキスト */
.pfc-bar-info {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray);
}

/* バーのトラック（背景） */
.pfc-bar-track {
  background: var(--gray-light);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

/* バーの塗り部分 */
.pfc-bar-fill {
  height: 100%;
  border-radius: 99px;
  width: 0%;
  transition: width 0.6s ease;
}

/* PFC各色 */
.pfc-p { color: #4CAF50; }
.pfc-f { color: #FFC107; }
.pfc-c { color: var(--orange); }

.pfc-fill-p { background: #4CAF50; }
.pfc-fill-f { background: #FFC107; }
.pfc-fill-c { background: var(--orange); }

/* ① PFC入力フィールド（食事追加モーダル内） */
.pfc-inputs {
  display: flex;
  gap: 8px;
}

.pfc-input-wrap {
  flex: 1;
  min-width: 0; /* flexアイテムが正しく縮むために必要 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pfc-input-label {
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

/* PFC入力欄のサイズ調整 */
.pfc-input {
  width: 100% !important;
  padding: 10px 2px !important;
  text-align: center;
  font-size: 0.9rem !important;
  box-sizing: border-box;
}

.pfc-input-unit {
  font-size: 0.65rem;
  color: var(--gray);
  font-weight: 600;
}

/* ① PFC目標（計算結果カード内） */
.calc-pfc-wrap {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 14px;
}

.calc-pfc-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  text-align: center;
}

.calc-pfc-row {
  display: flex;
  justify-content: space-around;
}

.calc-pfc-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  text-align: center;
  flex-direction: column;
  align-items: center;
}

.calc-pfc-label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.calc-pfc-val {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--white);
  line-height: 1;
}

.calc-pfc-unit {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.35);
}

/* ============================================
   ② 運動セクション（ホーム画面）
   ============================================ */

/* セクションヘッダー（タイトル + 追加ボタン横並び） */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

/* セクション内の追加ボタン */
.section-add-btn {
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* 運動アイテム行 */
.exercise-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-light);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 7px;
  font-size: 0.88rem;
}

.exercise-item-name {
  font-weight: 600;
  color: var(--black);
}

.exercise-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exercise-item-kcal {
  font-weight: 700;
  color: #4CAF50; /* 運動は緑色 */
}

.exercise-item-del {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* 消費カロリー合計 */
.exercise-total {
  font-size: 0.8rem;
  font-weight: 700;
  color: #4CAF50;
  text-align: right;
  padding-top: 4px;
}

/* 運動セクション：消費0のときグレーアウト */
.exercise-section-dim {
  opacity: 0.5;
}

/* ② 運動追加モーダル内：よく使う運動ボタン */
.exercise-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.exercise-preset-btn {
  padding: 7px 12px;
  border: 1.5px solid #E0E0E0;
  border-radius: 20px;
  background: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.exercise-preset-btn.active,
.exercise-preset-btn:active {
  border-color: var(--orange);
  background: var(--orange-pale);
  color: var(--orange);
}

/* 消費カロリー行（input + 計算ボタン） */
.exercise-kcal-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.btn-calc-exercise {
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-calc-exercise:active { opacity: 0.75; }

/* ============================================
   ③ 体重画面：体脂肪率入力行
   ============================================ */
.weight-fatrate-row {
  margin-top: -8px;
  margin-bottom: 8px;
}

/* 小さめの体脂肪率入力欄 */
.weight-input-sm {
  font-size: 2rem !important;
  width: 100px !important;
}

/* 体脂肪率のラベル */
.weight-unit-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  margin-bottom: 6px;
  align-self: flex-end;
}

/* 履歴リスト：体脂肪率の表示 */
.weight-item-fatrate {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4CAF50;
}
