/* ゆうこレシピ集 — 色や寸法の根拠は DESIGN_DIRECTION.md（消耗品リストと同じ配色・書体） */

:root {
  --ground: #F8F1EE;
  --surface: #FFFFFF;
  --paper: #FFFCFA;
  --line: #EFE2DF;
  --ink: #3B2D31;
  --ink-2: #76636A;
  --accent: #9E4D67;
  --accent-soft: #F7E6EA;
  --card-rule: rgba(158, 77, 103, .45);
  --danger: #B3362B;
  --control-line: #9A8086;
  --viewer: #1E1719;
  --viewer-ink: #F8F1EE;
  --ink-rgb: 59, 45, 49;

  --r-s: 8px;
  --r-m: 14px;
  --r-pill: 999px;

  --shadow: 0 1px 2px rgba(90, 50, 62, .10), 0 6px 18px rgba(90, 50, 62, .06);
  --ease: 160ms ease-out;

  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }

button, input, textarea { font: inherit; color: inherit; }

svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 画面には見せないが、押せば動く（写真を選ぶ input） */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}

/* ---- ボタン ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--ease), background-color var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { color: var(--accent); }
.btn.ghost:active { background: var(--accent-soft); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger-text { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:active { transform: none; }

.btn.icon { width: 44px; padding: 0; }
.btn.icon svg { width: 22px; height: 22px; stroke-width: 2.4; }

/* ---- 合言葉 ---- */

.lock {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lock-card {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.lock-card img { margin: 0 auto 4px; border-radius: 16px; }
.lock-card h1 { font-size: 22px; font-weight: 700; letter-spacing: .06em; font-feature-settings: "palt"; margin-bottom: 16px; }
.lock-card label { text-align: left; font-weight: 700; font-size: 14px; }
.lock-error { min-height: 1.5em; color: var(--danger); font-size: 14px; text-align: left; }

/* ---- 上のバー ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 0 8px;
  background: var(--ground);
}
.bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 20px;
}
.bar h1 { font-size: 20px; font-weight: 700; letter-spacing: .06em; font-feature-settings: "palt"; }

/* 検索 */
.search {
  position: relative;
  margin: 8px 12px 0;
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  width: 20px; height: 20px;
  transform: translateY(-50%);
  fill: none; stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 48px 10px 44px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--ink-2); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.search-clear {
  position: absolute;
  right: 2px; top: 50%;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
  transform: translateY(-50%);
  cursor: pointer;
}
.search-clear svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* よく使う食材 */
.suggest { padding: 12px 12px 2px; }
.suggest-title { padding: 0 8px 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.suggest-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest-chips button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--paper);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--ease);
}
.suggest-chips button:active { transform: scale(.97); }

/* カテゴリのしぼりこみ（横にスクロール） */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px 2px;
  scrollbar-width: none;
  scroll-padding: 0 12px;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(var(--ink-rgb), .07);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease), transform var(--ease);
}
.filter::after { content: ""; position: absolute; inset: -4px 0; }  /* 押せる範囲を 44px に */
.filter:active { transform: scale(.97); }
.filter[aria-pressed="true"] { background: var(--accent); color: #fff; }
.filter.manage { background: none; color: var(--accent); padding: 0 10px; }
.filter.manage svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.offline {
  max-width: 720px;
  margin: 0 auto 4px;
  padding: 8px 20px;
  font-size: 13px;
  color: #865219;
}

/* ---- 一覧 ---- */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 96px);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 32px;
  padding: 0 8px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.list-head .btn { min-height: 36px; padding: 0 10px; font-size: 14px; }

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rows li { position: relative; }
.rows li + li::before {
  content: "";
  position: absolute;
  top: 0; left: 88px; right: 0;
  border-top: 1px solid var(--line);
}

.row {
  width: 100%;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 20px;
  align-items: center;
  column-gap: 12px;
  min-height: 84px;
  padding: 10px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--ease);
}
.row:active { background: rgba(var(--ink-rgb), .04); }
.row .chev { width: 20px; height: 20px; fill: none; stroke: var(--control-line); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* 写真の小さい版。写真がないときは、罫線の入った小さなカード */
.thumb {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--accent-soft);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none {
  background:
    linear-gradient(var(--card-rule), var(--card-rule)) 10px 18px / calc(100% - 20px) 2px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 9px, rgba(158, 77, 103, .18) 9px 10px) 10px 26px / calc(100% - 20px) calc(100% - 36px) no-repeat,
    var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
}
.thumb-count {
  position: absolute;
  right: 4px; bottom: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: rgba(var(--ink-rgb), .72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.meta {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.meta-cat {
  display: inline-block;
  margin-right: 8px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: rgba(var(--ink-rgb), .06);
  font-size: 12px;
  font-weight: 700;
}

/* 空のとき */
.empty-all {
  margin: 12vh auto 0;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
}
.empty-all .thumb { width: 88px; height: 88px; transform: rotate(-4deg); margin-bottom: 8px; box-shadow: inset 0 0 0 1px var(--line), var(--shadow); }
.empty-all .big { font-size: 17px; font-weight: 700; color: var(--ink); }
.empty-all .btn { margin-top: 8px; }
.loading { margin-top: 20vh; text-align: center; color: var(--ink-2); }

/* ---- レシピ1つ ---- */

.detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 4px;
  padding-right: 8px;
  max-width: 1080px;
}
.back { padding-left: 8px; }
.back svg { width: 22px; height: 22px; stroke-width: 2.4; }

#detail { max-width: 1080px; }
.recipe { display: flex; flex-direction: column; gap: 16px; }
.recipe.single { max-width: 720px; margin: 0 auto; width: 100%; }

.recipe-head { padding: 4px 8px 4px; }
.recipe-cat {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.recipe-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  font-feature-settings: "palt";
  letter-spacing: .02em;
  overflow-wrap: anywhere;
}

.recipe-body { display: flex; flex-direction: column; gap: 16px; }
.recipe-photos { display: flex; flex-direction: column; gap: 12px; }
.photo {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: zoom-in;
  transition: transform var(--ease);
}
.photo:active { transform: scale(.99); }
.photo img { display: block; width: 100%; height: auto; background: var(--line); }
.photo-hint { padding: 0 8px; font-size: 13px; color: var(--ink-2); }

.recipe-text { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* レシピカード（シグネチャー）: 紙色・見出しの下にローズの罫・罫線 */
.card {
  padding: 14px 20px 18px;
  border-radius: var(--r-m);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.card h2 {
  padding-bottom: 8px;
  border-bottom: 2px solid var(--card-rule);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .04em;
}

.ing { list-style: none; margin: 0; padding: 0; }
.ing li {
  display: flex;
  align-items: baseline;
  min-height: 44px;
  padding: 10px 0 9px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.5;
}
.ing-name { overflow-wrap: anywhere; min-width: 0; }
.ing-leader {
  flex: 1 1 16px;
  min-width: 16px;
  margin: 0 8px;
  border-bottom: 2px dotted rgba(154, 128, 134, .65);
  transform: translateY(-4px);
}
.ing-amt {
  flex: none;
  max-width: 55%;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}
.ing li.ing-head {
  min-height: 0;
  padding: 16px 0 4px;
  border-bottom: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

/* 作り方は罫線のノートに書いたように */
.steps-text {
  --lh: 1.9em;
  margin-top: 6px;
  font-size: 16px;
  line-height: var(--lh);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--line) calc(var(--lh) - 1px));
  background-size: 100% var(--lh);
}

.source { align-self: flex-start; padding: 0 8px; }
.source svg { width: 16px; height: 16px; }
.recipe-foot {
  padding: 0 8px;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.missing { margin-top: 20vh; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }

@media (min-width: 900px) {
  .recipe-body.has-photos {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
  .recipe-head { padding-top: 8px; }
  .recipe-title { font-size: 28px; }
}

/* ---- 写真を大きく見る ---- */

.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--viewer);
  color: var(--viewer-ink);
  overflow: hidden;
}
.viewer::backdrop { background: #1E1719; }
.v-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
#v-img {
  position: absolute;
  max-width: none;
  transform-origin: 50% 50%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  will-change: transform;
}
#v-img.anim { transition: transform 200ms ease-out; }

.v-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 24px;
  background: linear-gradient(rgba(30, 23, 25, .72), rgba(30, 23, 25, 0));
  pointer-events: none;
}
.v-top > * { pointer-events: auto; }
.v-spacer { width: 44px; }
.v-count { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.v-btn {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(248, 241, 238, .28);
  border-radius: 50%;
  background: rgba(30, 23, 25, .62);   /* 明るい写真の上でも見えるように */
  color: var(--viewer-ink);
  cursor: pointer;
  transition: transform var(--ease), opacity var(--ease);
}
.v-btn:active { transform: scale(.94); }
.v-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.v-btn:focus-visible { outline-color: var(--viewer-ink); }
.v-nav { position: absolute; top: 50%; margin-top: -22px; }
.v-nav.prev { left: 12px; }
.v-nav.next { right: 12px; }
.v-nav:disabled { opacity: 0; pointer-events: none; }
.v-hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(30, 23, 25, .7);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 400ms ease-out;
}
.v-hint.gone { opacity: 0; }

/* ---- 追加・編集のシート ---- */

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 24px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -8px 32px rgba(70, 35, 48, .18);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(59, 45, 49, .38); }  /* ::backdrop は古い Safari で変数を受けつがない */
.sheet[open] { animation: sheet-in 220ms ease-out; }
@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 20px; }
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 20px);
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -20px;
  padding: 12px 8px 8px 20px;
  background: var(--surface);
}
.sheet-head h2 { font-size: 18px; font-weight: 700; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-size: 14px; font-weight: 700; padding: 0; }
.field legend { margin-bottom: 8px; }
.hint { font-size: 13px; color: var(--ink-2); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }

input:not([type]), input[type="text"], input[type="password"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 500;
  -webkit-appearance: none;
  appearance: none;
}
textarea { min-height: 148px; line-height: 1.7; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9A8A8F; }
input[aria-invalid="true"] { border-color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--control-line);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease);
}
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips .add-cat {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px dashed var(--control-line);
  border-radius: var(--r-pill);
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* 写真の並び（編集シート） */
.photo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.photo-list:empty { display: none; }
.photo-row { display: flex; align-items: center; gap: 6px; }
.photo-thumb {
  flex: none;
  width: 64px; height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  display: grid;
  place-items: center;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--ease); }
.photo-label { flex: 1; min-width: 0; padding-left: 6px; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.photo-label small { display: block; font-size: 12px; }
.photo-add { display: flex; flex-wrap: wrap; gap: 8px; }

.step {
  flex: none;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--control-line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: transform var(--ease), background-color var(--ease);
}
.step svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.step:active { transform: scale(.94); background: var(--accent-soft); }
.step.danger { color: var(--danger); }
.step:disabled { opacity: .35; cursor: default; }
.step:disabled:active { transform: none; background: var(--surface); }

/* カテゴリ（編集シートの中と、カテゴリを編集するシート） */
.new-cat { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.new-cat input { flex: 1; min-width: 0; }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 6px; }
.cat-row input { flex: 1; min-width: 0; }

.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ---- お知らせ ---- */

.toast {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
  animation: toast-in 200ms ease-out;
}
@keyframes toast-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.toast-msg {
  max-width: 480px;
  padding: 12px 18px;
  border-radius: var(--r-m);
  background: var(--paper);
  box-shadow: 0 2px 3px rgba(70, 35, 48, .16), 0 10px 20px rgba(70, 35, 48, .12);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
