/* ===========================================================================
   みんなの献立 — デザインシステム
   食欲をそそる暖色・角丸カード・余白多め・モバイルファースト。
   依存ライブラリなしのバニラCSS。
   =========================================================================== */

:root {
  /* 配色 */
  --bg:        #fbf6ef;        /* クリーム地 */
  --surface:   #ffffff;
  --surface-2: #fbf3ea;
  --ink:       #2c2420;        /* 文字 */
  --ink-soft:  #6f635a;        /* 補助文字 */
  --line:      #ece2d6;        /* 罫線 */

  --brand:     #e8632a;        /* トマトオレンジ */
  --brand-ink: #ffffff;
  --brand-soft:#fdeee6;

  --ok:        #2e9e5b;        /* 全員OK（緑） */
  --ok-bg:     #e7f6ec;
  --warn:      #d98a13;        /* 苦手（琥珀） */
  --warn-bg:   #fdf2dd;
  --danger:    #d4453e;        /* アレルギー（赤） */
  --danger-bg: #fbe6e5;

  --shadow:    0 2px 4px rgba(60, 40, 20, .05), 0 8px 24px rgba(60, 40, 20, .07);
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, .06), 0 2px 8px rgba(60, 40, 20, .05);
  --radius:    18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --maxw: 560px;
}

* { box-sizing: border-box; }

/* hidden属性を常に優先（.field 等の display:flex に負けないように） */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3 { line-height: 1.4; margin: 0; }

button { font-family: inherit; }

/* --------------------------------------------------------- アプリバー */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: max(env(safe-area-inset-top), 10px) 16px 10px;
  background: rgba(251, 246, 239, .85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar__home {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 4px 6px;
  margin-left: -6px;
  cursor: pointer;
  color: var(--ink);
  border-radius: var(--radius-sm);
}
.appbar__home:active { background: var(--surface-2); }
.appbar__logo { font-size: 24px; line-height: 1; }
.appbar__title { font-size: 17px; font-weight: 800; letter-spacing: .02em; }

/* --------------------------------------------------------- レイアウト */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 96px;
}
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

/* --------------------------------------------------------- 共通パーツ */
.stack    { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row      { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted    { color: var(--ink-soft); }
.center   { text-align: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.lead {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 4px 0 0;
}

/* --------------------------------------------------------- ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--block { width: 100%; }
.btn--primary {
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 6px 16px rgba(232, 99, 42, .28);
}
.btn--primary:hover { background: #d9571f; }
.btn--primary:disabled {
  background: #e9d8cd;
  color: #b3a194;
  box-shadow: none;
  cursor: not-allowed;
}
.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { min-height: 40px; padding: 8px 16px; font-size: 14px; }
.btn--icon {
  min-height: 40px;
  min-width: 40px;
  padding: 8px;
  border-radius: var(--radius-pill);
  background: none;
  border: 0;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 18px;
}
.btn--icon:hover { background: var(--surface-2); color: var(--danger); }

/* --------------------------------------------------------- ホーム */
.hero { text-align: center; padding: 12px 4px 4px; }
.hero__emoji { font-size: 52px; line-height: 1; }
.hero__title { font-size: 26px; font-weight: 800; margin-top: 10px; }
.hero__sub   { font-size: 15px; color: var(--ink-soft); margin-top: 8px; }

.choice {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 18px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
  color: var(--ink);
}
.choice:hover { box-shadow: var(--shadow); border-color: #e3d2c2; transform: translateY(-1px); }
.choice:active { transform: translateY(0); }
.choice__icon {
  flex: none;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: var(--brand-soft);
  font-size: 28px;
}
.choice__body { flex: 1; min-width: 0; }
.choice__title { font-size: 17px; font-weight: 800; }
.choice__desc  { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.choice__arrow { flex: none; color: var(--ink-soft); font-size: 20px; }

/* --------------------------------------------------------- 戻る */
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 4px;
  margin: -6px 0 8px -4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.back:hover { color: var(--ink); }

.page-title { font-size: 22px; font-weight: 800; }

/* --------------------------------------------------------- フォーム */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field__hint { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  font-size: 16px; /* iOSのズーム防止 */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: #b9a99c; }

/* 種別セグメント（好き/苦手/アレルギー） */
.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segment__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s ease;
}
.segment__btn .emo { font-size: 20px; }
.segment__btn[aria-pressed="true"][data-kind="LIKE"]    { border-color: var(--ok);     background: var(--ok-bg);     color: var(--ok); }
.segment__btn[aria-pressed="true"][data-kind="DISLIKE"] { border-color: var(--warn);   background: var(--warn-bg);   color: var(--warn); }
.segment__btn[aria-pressed="true"][data-kind="ALLERGY"] { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* --------------------------------------------------------- 食材オートコンプリート */
.ac { position: relative; }
.ac__menu {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 30;
  max-height: 248px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.ac__item {
  padding: 11px 14px;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface-2);
}
.ac__item:last-child { border-bottom: 0; }
.ac__item--active,
.ac__item:hover { background: var(--brand-soft); }
.ac__item .grp { color: var(--ink-soft); font-size: 12px; margin-left: 6px; }
/* 献立判定に使われないマイナー食材（成分表取り込み）は淡色で下位に。 */
.ac__item--dim { color: var(--ink-soft); opacity: .7; }
.ac__empty { padding: 12px 14px; color: var(--ink-soft); font-size: 14px; }

/* --------------------------------------------------------- 好み一覧（チップ） */
.prefs { display: flex; flex-direction: column; gap: 8px; }
.pref-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
}
.pref-chip__badge {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}
.pref-chip__name { flex: 1; min-width: 0; font-weight: 600; }
.pref-chip__name .sub { color: var(--ink-soft); font-weight: 400; font-size: 13px; }
.k-LIKE    { background: var(--ok-bg);     color: var(--ok); }
.k-DISLIKE { background: var(--warn-bg);   color: var(--warn); }
.k-ALLERGY { background: var(--danger-bg); color: var(--danger); }

.empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 22px 12px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------- 参加者カード */
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.person__avatar {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  font-size: 18px;
}
.person__body { flex: 1; min-width: 0; }
.person__name { font-weight: 700; }
.person__meta { font-size: 13px; color: var(--ink-soft); }

/* --------------------------------------------------------- トグル（全員が好きなものだけ） */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.toggle__text { font-size: 14px; font-weight: 600; }
.toggle__hint { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.switch {
  flex: none;
  position: relative;
  width: 50px; height: 30px;
  border-radius: var(--radius-pill);
  background: #ddd0c4;
  transition: background .18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle input:checked + .switch { background: var(--brand); }
.toggle input:checked + .switch::after { transform: translateX(20px); }

/* --------------------------------------------------------- 結果カード */
.result-summary {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 2px 0 4px;
}
.dish {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.dish--OK      { border-left: 5px solid var(--ok); }
.dish--DISLIKE { border-left: 5px solid var(--warn); }
.dish--ALLERGY { border-left: 5px solid var(--danger); }
.dish__head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.dish__name { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; }
.dish__status {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.dish__status--OK      { background: var(--ok-bg);     color: var(--ok); }
.dish__status--DISLIKE { background: var(--warn-bg);   color: var(--warn); }
.dish__status--ALLERGY { background: var(--danger-bg); color: var(--danger); }
.dish__caret { flex: none; color: var(--ink-soft); transition: transform .18s ease; }
.dish--open .dish__caret { transform: rotate(180deg); }
.dish__detail {
  padding: 0 16px 14px;
  border-top: 1px solid var(--surface-2);
}
.dish__detail ul { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.dish__detail li { font-size: 14px; display: flex; gap: 8px; }
.dish__detail .who { font-weight: 700; flex: none; }
.dish__detail .ok  { color: var(--ok); }
.verdict-dot { flex: none; }

/* セクション見出し（結果のグループ：全員OK / 配慮が必要） */
.group-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 800; color: var(--ink);
  margin: 20px 2px 2px;
}

/* カテゴリ小見出し（焼き物・揚げ物 …） */
.cat-head {
  font-size: 12px; font-weight: 800; letter-spacing: .03em;
  color: var(--ink-soft);
  margin: 12px 2px 2px;
}

/* 折りたたみ可能なセクション見出し（配慮が必要） */
.group-head--btn {
  width: 100%;
  justify-content: space-between;
  background: none;
  border: 0;
  padding: 6px 2px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}
.group-head--btn .care-caret { color: var(--ink-soft); font-size: 13px; }
.care-body { display: flex; flex-direction: column; gap: 10px; }

/* --------------------------------------------------------- 結果ヘッダー（固定） */
.result-head {
  position: sticky;
  top: var(--appbar-h, 56px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -16px;            /* .app の左右パディング分だけ広げて全幅の帯にする */
  padding: 10px 16px 12px;
  background: rgba(251, 246, 239, .94);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.result-head .result-summary { margin: 0; }
.result-search { min-height: 44px; }

/* ヘッダー内のコンパクトな厳格トグル */
.toggle--inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px;
  cursor: pointer;
}
.toggle--inline .toggle__text { flex: 1; font-size: 13px; font-weight: 700; color: var(--ink); }

/* カテゴリチップ（横スクロール） */
.cat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 2px 16px 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:active { transform: scale(.97); }
.chip--on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.result-body { display: flex; flex-direction: column; gap: 10px; }

/* --------------------------------------------------------- 上へ戻るFAB */
.to-top {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 40;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.to-top--show { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* --------------------------------------------------------- トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  background: #2c2420;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--danger { background: var(--danger); }

/* --------------------------------------------------------- 共有モーダル */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: end center;
  background: rgba(40, 28, 20, .45);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%;
  max-width: var(--maxw);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgba(0,0,0,.18);
  animation: slideup .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -8px auto 14px; }
.sheet__title { font-size: 18px; font-weight: 800; text-align: center; }
.sheet__sub { font-size: 13px; color: var(--ink-soft); text-align: center; margin: 4px 0 16px; }
.url-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.url-box code {
  flex: 1; min-width: 0;
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink-soft);
}

@media (min-width: 600px) {
  .modal { place-items: center; }
  .sheet { border-radius: 22px; margin: 0 16px; }
}
