/* =========================================================
   トークン定義
   ========================================================= */
:root{
  --paper:      #EDF0E4;
  --paper-alt:  #F6F7EF;
  --ink:        #2B2E22;
  --ink-soft:   #5B5E4E;
  --line:       #D6D8C6;

  --sage:       #5C7A52;
  --sage-dark:  #3E5636;
  --gold:       #E6A94A;
  --gold-soft:  #F6E3BC;
  --vermillion: #C1432F;
  --vermillion-dark: #9C3323;

  --card-bg:    #FFFFFF;
  --shadow:     0 6px 16px rgba(43, 46, 34, 0.10);
  --shadow-lg:  0 12px 32px rgba(43, 46, 34, 0.22);

  --radius-s:   10px;
  --radius-m:   16px;
  --radius-l:   22px;

  --font-display: "Zen Maru Gothic", "Noto Sans JP", sans-serif;
  --font-body:    "Noto Sans JP", sans-serif;
  --font-mono:    "JetBrains Mono", monospace;

  --tap-min: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body{
  padding-bottom: calc(96px + var(--safe-bottom));
  min-height: 100vh;
}

h1, h2{ margin: 0; font-family: var(--font-display); }
p{ margin: 0; }

button{ font-family: inherit; }

/* =========================================================
   ヘッダー
   ========================================================= */
.app-header{
  position: relative;
  padding: 34px 20px 26px;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(230,169,74,0.28), transparent 55%),
    var(--sage-dark);
  color: var(--paper-alt);
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  overflow: hidden;
}

.app-header__mark{
  width: 40px;
  height: 40px;
  color: var(--gold);
  margin-bottom: 10px;
}
.app-header__mark svg{ width: 100%; height: 100%; }

.app-header__title{
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.app-header__subtitle{
  margin-top: 6px;
  font-size: 14px;
  color: rgba(246, 247, 239, 0.82);
}

/* =========================================================
   メイン / パネル共通
   ========================================================= */
.app-main{
  padding: 18px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
}

.panel{
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 16px 16px 18px;
}

.panel--selected{
  background: var(--gold-soft);
  border-color: #E7D2A0;
  padding: 12px 16px;
}

.panel__head{
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel__eyebrow{
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--sage-dark);
  background: rgba(92, 122, 82, 0.14);
  padding: 3px 8px;
  border-radius: 20px;
}

.panel__title{
  font-size: 17px;
  font-weight: 700;
}

.panel__count{
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
}

/* =========================================================
   食材チップ（選択すると"判子"のようなマークが押される）
   ========================================================= */
.chip-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.chip{
  position: relative;
  min-height: var(--tap-min);
  padding: 10px 10px;
  border-radius: var(--radius-m);
  border: 1.5px solid var(--line);
  background: var(--card-bg);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.chip:active{ transform: scale(0.96); }

.chip[aria-pressed="true"]{
  background: var(--sage);
  border-color: var(--sage-dark);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: var(--shadow);
}

/* 選択された瞬間に押される"はんこ"の丸マーク */
.chip[aria-pressed="true"]::after{
  content: "";
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--gold);
  opacity: 0.95;
}
.chip[aria-pressed="true"]::before{
  content: "✓";
  position: absolute;
  top: -3px;
  right: 2px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

/* =========================================================
   選択中食材の表示
   ========================================================= */
.selected-row{
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.selected-row__label{
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-dark);
  white-space: nowrap;
}

.selected-row__text{
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}

.selected-row__text.is-empty{
  color: var(--ink-soft);
  font-weight: 400;
}

/* =========================================================
   調理時間（セグメントコントロール）
   ========================================================= */
.segmented{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.segmented__btn{
  min-height: var(--tap-min);
  border-radius: var(--radius-s);
  border: 1.5px solid var(--line);
  background: var(--card-bg);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.segmented__btn[aria-checked="true"]{
  background: var(--vermillion);
  border-color: var(--vermillion-dark);
  color: #fff;
}

/* =========================================================
   検索結果エリア
   ========================================================= */
.result-area{
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint-text{
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.7;
  padding: 6px 2px;
}

.empty-result{
  text-align: center;
  padding: 30px 10px 10px;
}
.empty-result__title{
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.empty-result__hint{
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* =========================================================
   レシピカード
   ========================================================= */
.recipe-card{
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 14px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.recipe-card:active{ transform: scale(0.985); box-shadow: var(--shadow); }

.recipe-card__rank{
  position: absolute;
  top: -9px;
  left: 12px;
  background: var(--sage-dark);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
}

.recipe-card__top{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.recipe-card__name{
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}

.recipe-card__fav{
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold-soft);
  color: #B8862A;
  white-space: nowrap;
}

.recipe-card__meta{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.match-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(92,122,82,0.12);
  color: var(--sage-dark);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  padding: 4px 9px;
  border-radius: 20px;
}

.match-badge__dots{ letter-spacing: 1px; }

.tag{
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 20px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
}

.tag--time{ font-family: var(--font-mono); }

.tag--category{
  background: var(--gold-soft);
  border-color: #E7D2A0;
  color: #7A5A18;
}

.recipe-card__memo{
  margin-top: 9px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.recipe-card__memo::before{ content: "“"; }
.recipe-card__memo::after{ content: "”"; }

/* =========================================================
   検索ボタン（画面下部固定・親指ゾーン）
   ========================================================= */
.search-bar{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(237,240,228,0) 0%, var(--paper) 28%);
  z-index: 30;
}

.search-bar__warning{
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--vermillion-dark);
  margin-bottom: 6px;
}

.search-button{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 56px;
  border: none;
  border-radius: 999px;
  background: var(--vermillion);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
.search-button:active{
  transform: scale(0.97);
  background: var(--vermillion-dark);
}

/* =========================================================
   詳細モーダル
   ========================================================= */
.modal{
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
.modal[hidden]{ display: none; }

.modal__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(43, 46, 34, 0.48);
}

.modal__sheet{
  position: relative;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper-alt);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 20px calc(28px + var(--safe-bottom));
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up{
  from{ transform: translateY(24px); opacity: 0; }
  to{ transform: translateY(0); opacity: 1; }
}

.modal__close{
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal__title{
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  padding-right: 40px;
}

.modal__fav{
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: #B8862A;
}

.modal__row{
  margin-top: 16px;
}
.modal__row-label{
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--sage-dark);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.modal__ingredients{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.modal__ingredient-tag{
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--card-bg);
  border: 1px solid var(--line);
}
.modal__ingredient-tag.is-selected{
  background: var(--sage);
  border-color: var(--sage-dark);
  color: #fff;
  font-weight: 700;
}

.modal__memo{
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 12px 14px;
}

.modal__steps{
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--ink-soft);
}

/* =========================================================
   アクセシビリティ / レスポンシブ
   ========================================================= */
:focus-visible{
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

@media (min-width: 420px){
  .chip-grid{ grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
