/* size-fit の配色設計をそのまま引き継いでいる（同じ人が使う、大人向けの道具なので）。
   知育アプリ側（akamisa配下）とは対象が違うため、見た目も意図的に分けている。

   ただし size-fit が「角丸ゼロ・彩度を抑えた黒基調」でZOZOに寄せていたのに対し、
   こちらは台所で立ったまま見るものなので、行間と押せるものの当たり判定を広めにし、
   少しだけ丸みを持たせている。 */

:root {
  --bg: #faf9f6;
  --panel: #ffffff;
  --ink: #1e1e1e;
  --ink-soft: #6f6b63;
  --line: #e4e1da;
  --accent: #23201b;
  --accent-ink: #ffffff;

  --good: #0f9d58;
  --caution: #b8722a;
  --bad: #d1453b;
  --good-bg: #e8f6ee;
  --caution-bg: #fbf1e0;
  --bad-bg: #fdecea;

  --radius: 6px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --panel: #201e19;
    --ink: #eceae4;
    --ink-soft: #a5a096;
    --line: #38352d;
    --accent: #eceae4;
    --accent-ink: #1a1a1a;
    --good: #4ade80; --caution: #e0a35f; --bad: #f87171;
    --good-bg: #12331f; --caution-bg: #3a2c14; --bad-bg: #3a1d1b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", -apple-system, BlinkMacSystemFont, "Yu Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 680px; margin: 0 auto; padding: 20px 16px 72px; }

.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- ヘッダー ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.app-bar h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.icon-btn {
  border: 0; background: transparent; color: var(--ink);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 6px;
}

/* ---------- 見出し・文章 ---------- */
.section-title {
  font-size: 12px; font-weight: 700; color: var(--ink-soft); margin: 28px 0 10px;
  letter-spacing: .08em;
}
.hint { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; }
.warn {
  font-size: 13px; margin: 0 0 14px; padding: 10px 12px;
  background: var(--caution-bg); border-radius: var(--radius); color: var(--ink);
}
.notes {
  font-size: 13px; padding: 10px 12px; margin: 0 0 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.counts { font-size: 14px; margin: 0 0 8px; }
.counts b { font-size: 18px; }
.empty-note { padding: 32px 0; }
.intro-lead { font-size: 17px; margin: 0 0 8px; }
.intro-sub { color: var(--ink-soft); margin: 0; }

.source-panel { margin: 0 0 20px; }
.source-panel summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); }
.source-panel pre {
  margin: 10px 0 0; padding: 12px; max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}

/* ---------- 入力 ---------- */
.field { display: block; margin-bottom: 18px; }
.field-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin-bottom: 6px; letter-spacing: .06em;
}
input[type="text"], input[type="url"], input[type="search"], textarea, select {
  width: 100%; padding: 10px 12px;
  font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
textarea {
  resize: vertical; overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn {
  flex: 1; min-width: 90px; padding: 9px 12px;
  font: inherit; font-size: 14px; cursor: pointer;
  background: var(--panel); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.seg-btn.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

.drop-zone {
  display: flex; align-items: center; justify-content: center;
  min-height: 150px; padding: 16px; cursor: pointer; text-align: center;
  color: var(--ink-soft); background: var(--panel);
  border: 2px dashed var(--line); border-radius: var(--radius);
}
.drop-zone img { max-width: 100%; max-height: 320px; }

.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check-row input { margin-top: 6px; }

/* ---------- ボタン ---------- */
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.btn {
  padding: 13px 18px; font: inherit; font-size: 15px; font-weight: 700;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  letter-spacing: .03em;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-sub { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-small { padding: 7px 12px; font-size: 13px; font-weight: 500; }

.status { margin-top: 12px; font-size: 14px; color: var(--ink-soft); }
.status.error { color: var(--bad); }

/* ---------- 一覧 ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }
.search-bar select { width: auto; flex: 0 0 auto; }

.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-name { font-weight: 700; font-size: 16px; }
.card-count {
  margin-left: auto; flex: 0 0 auto;
  font-size: 11px; font-weight: 700; padding: 1px 8px;
  background: var(--accent); color: var(--accent-ink); border-radius: 99px;
}
.card-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.card-ing {
  font-size: 13px; color: var(--ink-soft); margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 材料の編集 ---------- */
.grp-block {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 10px; margin-bottom: 10px;
}
.grp-head { margin-bottom: 8px; }
.grp-input {
  font-size: 13px; font-weight: 700; padding: 6px 8px;
  background: transparent; border: 1px dashed var(--line);
}
.ing-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.ing-row input { padding: 8px 10px; }
.ing-row [data-k="item"]   { flex: 3; min-width: 0; }
.ing-row [data-k="amount"] { flex: 2; min-width: 0; }
.ing-row [data-k="note"]   { flex: 2; min-width: 0; }
/* AIが読めなかったところは色を変えて、目に留まるようにする */
.ing-row input.empty { background: var(--caution-bg); }

.row-tools { display: flex; flex: 0 0 auto; }
.row-btn {
  border: 0; background: none; color: var(--ink-soft);
  cursor: pointer; font-size: 15px; padding: 4px 5px; line-height: 1;
}
.row-btn:hover { color: var(--ink); }

/* ---------- 作り方の編集 ---------- */
.step-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.step-no {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); border-radius: 99px;
}
.step-row textarea { flex: 1; min-width: 0; }

/* ---------- 詳細 ---------- */
.detail-title { font-size: 21px; margin: 0 0 4px; line-height: 1.4; }
.detail-meta { font-size: 13px; color: var(--ink-soft); margin: 0; }
.detail-src { font-size: 13px; margin: 6px 0 0; }
.detail-src a { color: var(--ink); }

.servings-switch {
  margin-top: 20px; padding: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.servings-switch .seg { margin-top: 8px; }

.ing-group {
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin: 14px 0 4px; letter-spacing: .06em;
}
.di-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.di-row input { flex: 0 0 auto; }
/* チェックを入れたら薄くする。買い物や下ごしらえの途中経過なので、保存はしない */
.di-row:has(input:checked) { opacity: .45; }
.di-item { flex: 1; }
.di-note { font-size: 12px; color: var(--ink-soft); }
.di-amt { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; }
.di-orig { display: block; font-size: 11px; color: var(--ink-soft); }

.steps { padding-left: 1.4em; margin: 0; }
.steps li { margin-bottom: 10px; }

.tweak {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.tweak-at { flex: 0 0 auto; font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tweak-text { flex: 1; }
.tweak-add { display: flex; gap: 8px; margin-top: 10px; }
.tweak-add input { flex: 1; }
.tweak-add .btn { flex: 0 0 auto; }

details summary { cursor: pointer; font-size: 13px; color: var(--ink-soft); }
details[open] summary { margin-bottom: 10px; }
