/* ============================================================
   さくっと栄養計算 — スタイル
   ライト/ダーク対応・レスポンシブ・印刷（PDF）レイアウト込み
   ============================================================ */

:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #22302b;
  --ink-soft: #5b6b63;
  --line: #e2e8e0;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e7f3ec;
  --accent-soft-ink: #1d5c38;
  --energy: #d97706;
  --danger: #c2483f;
  --danger-soft: #fbeceb;
  --p-color: #3b82c4;
  --f-color: #e0a12f;
  --c-color: #5aa96e;
  --shadow: 0 1px 2px rgba(30, 45, 38, 0.06), 0 4px 16px rgba(30, 45, 38, 0.07);
  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14201a;
    --surface: #1c2a23;
    --surface-2: #22332b;
    --ink: #e8efe9;
    --ink-soft: #9db3a7;
    --line: #31453a;
    --accent: #4caf7d;
    --accent-ink: #0d1f16;
    --accent-soft: #26503a;
    --accent-soft-ink: #bfe6d0;
    --energy: #f0a94b;
    --danger: #e06c62;
    --danger-soft: #45211e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- ヘッダー ---------- */
.app-header {
  background: linear-gradient(135deg, var(--accent) 0%, #256b42 100%);
  color: #fff;
  padding: 26px 20px 30px;
}
.app-header__inner { max-width: 1180px; margin: 0 auto; }
.app-title {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 10px;
}
.app-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  margin: -5px 0;
  border-radius: 10px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.app-logo svg { width: 34px; height: 34px; display: block; }
.app-logo:hover { background: rgba(255, 255, 255, 0.14); }
.app-logo:active { transform: scale(0.94); }
.app-logo:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.app-subtitle {
  margin: 6px 0 0;
  font-size: 0.92rem;
  opacity: 0.92;
}

/* ---------- レイアウト ---------- */
.layout {
  max-width: 1180px;
  margin: 20px auto 40px;
  padding: 0 16px 40px;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr) 430px; align-items: start; }
  .col--menu { position: sticky; top: 66px; } /* 常設タブバーの下に収める */
}
/* 単一カラムのタブ（栄養チェック・保存・1日） */
.layout--single { max-width: 760px; }
@media (min-width: 980px) {
  .layout--single,
  .layout--check { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- タブナビ ---------- */
.panel[hidden] { display: none !important; }

.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.tab-nav__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 16px;
  overflow-x: auto;
}
.tab-nav__tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 13px 16px 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-nav__tab:hover { color: var(--ink); }
.tab-nav__tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 下部ナビ（モバイル） ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__tab {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: none;
}
.bottom-nav__tab .icon { width: 22px; height: 22px; }
.bottom-nav__tab[aria-current="page"] { color: var(--accent); }
@media (min-width: 980px) { .bottom-nav { display: none; } }

/* ---------- 栄養チェックパネル ---------- */
.totals__check-link { width: 100%; margin-top: 12px; }
.check-summary {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.check-summary__name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.check-summary .totals__energy { padding: 0; text-align: right; }
.check-summary .totals__energy-value { font-size: 1.9rem; }
.check-section-title {
  margin: 20px 0 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

/* 栄養チェック: モバイルは目安比較を先に、詳細テーブルは折りたたみ */
.layout--check { max-width: 1180px; }
.check-columns { display: flex; flex-direction: column; }
.check-col--dri { order: -1; }
.check-details__summary { cursor: pointer; }
.check-details__summary:hover { color: var(--accent); }
.check-details__heading { display: inline; font-size: inherit; margin: 0; }

/* PC: 2カラム。右（目安比較）は sticky、詳細テーブルは常時展開 */
@media (min-width: 980px) {
  .check-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 32px;
    align-items: start;
  }
  .check-col--dri { order: 0; position: sticky; top: 66px; }
  .check-details__summary { pointer-events: none; list-style: none; }
  .check-details__summary:hover { color: inherit; }
  .check-details__summary::-webkit-details-marker { display: none; }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card__title {
  margin: 0 0 4px;
  font-size: 1.12rem;
  display: flex; align-items: center; gap: 10px;
}
.card__hint {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.step-badge {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.9rem;
  font-weight: 700;
  flex: none;
}

/* ---------- 検索 ---------- */
.search-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.search-box {
  flex: 1 1 240px;
  position: relative;
  display: flex; align-items: center;
}
.search-box__icon {
  position: absolute; left: 12px;
  font-size: 0.95rem;
  pointer-events: none;
}
.search-box__input {
  width: 100%;
  padding: 11px 38px 11px 38px;
  font-size: 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box__input::-webkit-search-cancel-button {
  -webkit-appearance: none; /* 自作クリアボタンと二重になるため非表示 */
}
.search-box__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box__clear {
  position: absolute; right: 8px;
  border: none; background: var(--line);
  color: var(--ink-soft);
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}
.search-box__clear:hover { background: var(--danger-soft); color: var(--danger); }
.group-select-wrap { flex: 0 1 auto; }
.group-select {
  height: 100%;
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.92rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.group-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.result-count {
  margin: 4px 0 8px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ---------- 食品リスト ---------- */
.food-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 62vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.food-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.food-item:hover { border-color: var(--accent); background: var(--surface-2); }
.food-item__main { flex: 1 1 auto; min-width: 0; }
.food-item__name {
  font-size: 0.95rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.food-item__meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.food-item__group-tag {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  font-size: 0.72rem;
}
.food-item__kcal { color: var(--energy); font-weight: 700; }
.food-item__add {
  flex: none;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
  min-width: 64px;
}
.food-item__add:hover { filter: brightness(1.08); }
.food-item__add:active { transform: scale(0.95); }
.food-item__add.is-added { background: var(--accent-soft); color: var(--accent-soft-ink); }
.food-list__more { text-align: center; margin-top: 12px; }
.food-list__section {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 2px 2px;
  letter-spacing: 0.03em;
}

/* ---------- アイコン（Lucide由来のSVGスプライト） ---------- */
.icon-defs {
  position: absolute;
  width: 0; height: 0;
  overflow: hidden;
}
.icon {
  width: 1.1em; height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
  flex: none;
}
.icon--lg { width: 1.8em; height: 1.8em; }

/* ---------- ボタン共通 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--accent { background: var(--energy); color: #fff; }
.btn--accent:hover { filter: brightness(1.06); }
.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn--ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 編集中バナー */
.edit-banner[hidden] { display: none !important; }
.edit-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
}
.edit-banner__text {
  margin: 0;
  flex: 1 1 200px;
  font-size: 0.85rem;
  color: var(--accent-soft-ink);
  overflow-wrap: anywhere;
}
.edit-banner__cancel { flex: none; padding: 7px 12px; font-size: 0.82rem; }

/* ---------- 献立 ---------- */
.menu-name-wrap { display: block; margin-bottom: 14px; }
.menu-name-label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.menu-name-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
}
.menu-name-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.menu-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.menu-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
}
.menu-item.is-flash { animation: flash-bg 1.2s ease; }
@keyframes flash-bg {
  0%, 60% { background: var(--accent-soft); border-color: var(--accent); }
  100% { background: var(--surface-2); }
}
.menu-item__top { display: flex; align-items: flex-start; gap: 8px; }
.menu-item__name {
  flex: 1 1 auto;
  font-size: 0.92rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.menu-item__remove {
  flex: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}
.menu-item__remove:hover { background: var(--danger-soft); color: var(--danger); }
.menu-item__bottom {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.gram-stepper { display: inline-flex; align-items: center; gap: 0; }
.gram-stepper__btn {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 34px; height: 36px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
}
.gram-stepper__btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.gram-stepper__btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.gram-stepper__btn:hover { background: var(--accent-soft); }
.gram-stepper__input {
  width: 70px; height: 36px;
  border: 1.5px solid var(--line);
  border-left: none; border-right: none;
  text-align: right;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 0 6px;
  background: var(--surface);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.gram-stepper__input::-webkit-outer-spin-button,
.gram-stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gram-stepper__input:focus { outline: none; border-color: var(--accent); }
.gram-unit { font-size: 0.85rem; color: var(--ink-soft); }
.menu-item__kcal {
  margin-left: auto;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--energy);
  font-variant-numeric: tabular-nums;
}

/* 目安量チップ */
.portion-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.portion-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-soft-ink);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.portion-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.portion-chip:active { transform: scale(0.96); }
.portion-chip--add { border-style: dashed; }

/* ---------- 食品｜料理の切替と料理プリセット ---------- */
.source-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.source-toggle__btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.source-toggle__btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-soft-ink);
}
.dish-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.dish-list[hidden] { display: none !important; }
.food-list[hidden] { display: none !important; }
.dish-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
}
.dish-item .food-item__main { flex: 1; min-width: 0; }
.dish-item__controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.dish-item__servings {
  width: 4em;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  text-align: center;
  background: var(--surface);
  color: inherit;
}
.dish-item__unit { font-size: 0.78rem; color: var(--ink-soft); }

/* 「具を追加」中のバナー */
.dish-target-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.dish-target-banner[hidden] { display: none !important; }
.dish-target-banner__text {
  margin: 0;
  flex: 1;
  font-size: 0.85rem;
  color: var(--accent-soft-ink);
}
.dish-target-banner__clear { flex-shrink: 0; }

/* 献立内の料理グループ見出し */
.menu-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px 0;
  border-top: 2px solid var(--line);
  margin-top: 4px;
}
.menu-group:first-child { border-top: none; margin-top: 0; }
.menu-group__name {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-soft-ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.menu-group--singles .menu-group__name { color: var(--ink-soft); }
.menu-group__kcal { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); flex-shrink: 0; }
.menu-group__btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-soft-ink);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.menu-group__btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.menu-group__btn--remove { color: var(--danger, #b3261e); }
.menu-item--grouped { margin-left: 14px; }

.menu-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
  padding: 22px 8px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
}
.menu-empty__icon { font-size: 1.8rem; margin: 0 0 4px; }
.menu-empty p { margin: 0; }

/* ---------- 合計 ---------- */
.totals { margin-top: 16px; }
.totals__energy {
  text-align: center;
  padding: 12px 0 6px;
}
.totals__energy-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--energy);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.totals__energy-unit { font-size: 1rem; color: var(--ink-soft); margin-left: 4px; }
.totals__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}
.total-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
}
.total-chip__label { font-size: 0.72rem; color: var(--ink-soft); display: block; }
.total-chip__value {
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.total-chip__unit { font-size: 0.7rem; color: var(--ink-soft); margin-left: 2px; }

/* PFC バー */
.pfc { margin: 6px 0 4px; }
.pfc__title { margin: 0 0 6px; font-size: 0.78rem; color: var(--ink-soft); }
.pfc__bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
.pfc__seg { transition: width 0.35s ease; }
.pfc__seg--p { background: var(--p-color); }
.pfc__seg--f { background: var(--f-color); }
.pfc__seg--c { background: var(--c-color); }
.pfc__legend {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.pfc__legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot--p { background: var(--p-color); }
.dot--f { background: var(--f-color); }
.dot--c { background: var(--c-color); }

/* 詳細テーブル */
.totals__details { margin-top: 12px; font-size: 0.88rem; }
.totals__details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding: 6px 0;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.detail-table th, .detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.85rem;
}
.detail-table td:last-child, .detail-table th:last-child { text-align: right; }
.detail-note { font-size: 0.75rem; color: var(--ink-soft); margin: 8px 0 0; }

/* 食事摂取基準バー */
.dri-profile {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 10px 0 12px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.dri-profile label { display: flex; align-items: center; gap: 6px; }
.dri-select {
  padding: 6px 10px;
  font-size: 0.88rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.dri-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dri-empty { font-size: 0.82rem; color: var(--ink-soft); margin: 4px 0; }
.dri-bars { display: flex; flex-direction: column; gap: 9px; }
.dri-row__head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
  font-size: 0.78rem;
  margin-bottom: 3px;
}
.dri-row__label { color: var(--ink); font-weight: 600; flex: none; }
.dri-row__value { color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: right; }
.dri-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.dri-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.dri-bar__fill.is-full { background: var(--p-color); }
.dri-bar__fill.is-warn { background: var(--f-color); }
.dri-bar__fill.is-over { background: var(--danger); }

/* 1日の合計 */
.dayplan-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.dayplan-slot {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.dayplan-select { width: 100%; min-height: 38px; }
.dayplan-total {
  text-align: center;
  padding: 6px 0 10px;
}
.dayplan-total__value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--energy);
  font-variant-numeric: tabular-nums;
}
.dayplan-total__unit { font-size: 0.85rem; color: var(--ink-soft); margin-left: 4px; }
#dayplan-summary .dri-profile { margin-top: 0; }

/* バックアップ操作 */
.backup-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px;
}
.backup-actions .btn { flex: 1 1 auto; padding: 9px 10px; font-size: 0.82rem; }
.backup-hint { margin-top: 8px; }

.menu-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 18px;
}
.menu-actions .btn { flex: 1 1 auto; }

/* ---------- 保存済み献立 ---------- */
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.saved-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.saved-item.is-editing { border-color: var(--accent); background: var(--accent-soft); }
.saved-item__main { flex: 1 1 160px; min-width: 0; }
.saved-item__name { font-weight: 700; font-size: 0.92rem; overflow-wrap: anywhere; }
.saved-item__meta { font-size: 0.76rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.saved-item__actions { display: flex; gap: 6px; flex: none; }
.saved-item__actions .btn { padding: 7px 12px; font-size: 0.8rem; }
.btn--danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger-soft);
}
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--danger-confirm,
.btn--danger-ghost.btn--danger-confirm {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
@media (prefers-color-scheme: dark) {
  .btn--danger-confirm,
  .btn--danger-ghost.btn--danger-confirm { color: #1a0b0a; }
}
.saved-empty { font-size: 0.85rem; color: var(--ink-soft); margin: 4px 0 0; }

/* ---------- モバイルバー ---------- */
.mobile-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom)); /* 下部ナビの上に載せる */
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  z-index: 30;
}
.mobile-bar__info { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.mobile-bar__info b { color: var(--energy); font-size: 1.1rem; }
.mobile-bar__btn { padding: 9px 16px; }
@media (min-width: 980px) { .mobile-bar { display: none !important; } }
@media (max-width: 979px) {
  .tab-nav { display: none; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-mobile-bar { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
  /* 食品リストは内部スクロールをやめてページスクロールに統一 */
  .food-list { max-height: none; overflow-y: visible; padding-right: 0; }
  /* 検索・分類はリストを深くスクロールしても使えるように sticky 化 */
  .search-controls {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    padding: 10px 0 8px;
    margin: -10px 0 0;
  }
}

/* ---------- フッター ---------- */
.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 32px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 88px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toast-in 0.25s ease;
  max-width: min(90vw, 480px);
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
/* モバイルでは下部ナビ+モバイルバーの上に出す（.toastの基本定義より後に置くこと） */
@media (max-width: 979px) {
  .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* フォーカスリング（キーボード操作） */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   印刷（PDF出力）
   ============================================================ */
.print-sheet { display: none; }

@media print {
  body > *:not(.print-sheet) { display: none !important; }
  body { background: #fff; color: #111; }
  .print-sheet { display: block; padding: 0; font-size: 11pt; }

  .print-sheet h1 {
    font-size: 16pt;
    margin: 0 0 2pt;
    padding-bottom: 6pt;
    border-bottom: 2.5pt solid #2f7d4f;
  }
  .print-sheet .print-date { font-size: 9pt; color: #555; margin: 4pt 0 12pt; }

  .print-sheet table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14pt;
  }
  .print-sheet th, .print-sheet td {
    border: 0.6pt solid #999;
    padding: 4pt 6pt;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .print-sheet th { background: #eef4ef; font-size: 9pt; }
  .print-sheet th:first-child, .print-sheet td:first-child { text-align: left; }
  .print-sheet .print-total-row td { font-weight: 700; background: #f7f9f6; }
  .print-sheet .print-group-row td { font-weight: 700; background: #eef4f0; }

  .print-sheet h2 { font-size: 11pt; margin: 12pt 0 4pt; }
  .print-sheet .print-detail-table { width: auto; min-width: 60%; }
  .print-sheet .print-footnote { font-size: 8pt; color: #555; margin-top: 14pt; }

  @page { margin: 18mm 15mm; }
}

/* お気に入り（★） */
.food-item__fav {
  background: none;
  border: none;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  color: #b9b9b9;
  padding: 4px 2px;
  align-self: center;
}
.food-item__fav.is-fav { color: #f0a821; }

/* マイ料理 */
.recipe-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.recipe-form .menu-name-input { flex: 1; min-width: 8em; }
.recipe-form__servings { font-size: 0.9em; white-space: nowrap; }
.recipe-form__servings input,
.recipe-item__servings { width: 4em; }
.recipe-item__servings { margin-right: 4px; }

/* アドバイス（採点・不足補完） */
.advice {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed rgba(128, 128, 128, 0.4);
}
.advice__title { margin: 0 0 6px; font-size: 0.95rem; }
.advice__score { margin: 0 0 6px; }
.advice__score b { font-size: 1.4em; }
.advice__comments {
  margin: 0 0 8px;
  padding-left: 1.3em;
  font-size: 0.88em;
}
.suggest-group { margin-top: 8px; }
.suggest-group__title { font-size: 0.88em; font-weight: 600; margin-bottom: 4px; }
.suggest-btn { margin: 2px 6px 2px 0; font-size: 0.85em; }
