:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f6f9f7;
  --text: #24302a;
  --muted: #7a857f;
  --border: #e6ece8;
  --accent: #6aab84;        /* 柔らかい緑 */
  --accent-strong: #4f9269; /* 文字・ボタン用の少し濃い緑 */
  --accent-soft: #edf6f0;   /* 淡い緑の面 */
  --warn: #c98a12;
  --danger: #d0574f;
  --shadow: 0 2px 10px rgba(36, 48, 42, .06);
  --radius: 20px;
  --header-image: url("images/header.jpg");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a17;
    --surface: #1d2420;
    --surface-soft: #222a25;
    --text: #e5ece8;
    --muted: #97a39c;
    --border: #2c3630;
    --accent: #7fbf98;
    --accent-strong: #8fcca7;
    --accent-soft: #24342b;
    --warn: #e7ae45;
    --danger: #ec8179;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* ---- ヘッダー（写真＋タイトル） ---- */
.app-header {
  position: relative;
  min-height: 200px;
  display: flex; align-items: flex-end;
  padding: 24px 20px;
  color: #fff;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.05) 30%, rgba(0,0,0,.55)),
    var(--header-image) center / cover no-repeat,
    var(--accent);
  border-radius: 0 0 28px 28px;
}
.app-header__inner {
  width: 100%; max-width: 720px; margin: 0 auto;
  display: flex; align-items: baseline; gap: 12px;
}
.app-header h1 {
  margin: 0;
  font-size: 1.75rem; font-weight: 700; letter-spacing: .04em;
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.count {
  font-size: .9rem;
  padding: 2px 12px; border-radius: 999px;
  background: rgba(255,255,255,.22);
  backdrop-filter: blur(4px);
}
.count:empty { display: none; }
@media (min-width: 720px) {
  .app-header { min-height: 260px; padding: 32px 24px; }
  .app-header h1 { font-size: 2.1rem; }
}

main { max-width: 720px; margin: 0 auto; padding: 24px 20px 112px; }

/* ---- ツールバー ---- */
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; }
.toolbar input { flex: 1; min-width: 0; }

input, select, button {
  font: inherit; color: inherit;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface);
  padding: 10px 14px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button { cursor: pointer; }

/* ---- 在庫リスト ---- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.item {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 18px 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.info { flex: 1; min-width: 0; cursor: pointer; }
.name { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.meta { font-size: .84rem; color: var(--muted); margin-top: 4px; }
.meta .soon { color: var(--warn); font-weight: 600; }
.meta .expired { color: var(--danger); font-weight: 600; }

/* 数量0: 品名と期限だけ薄く（＋/−は通常の濃さ） */
.item.zero .info { opacity: .45; }
.item.zero .value { color: var(--muted); }

.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 40px; height: 40px; padding: 0;
  border: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 1.2rem; line-height: 1;
}
.qty button:hover { background: var(--accent); color: #fff; }
.qty .value {
  min-width: 3.8em; text-align: center;
  font-weight: 600; font-variant-numeric: tabular-nums;
}

.empty { text-align: center; color: var(--muted); margin-top: 56px; }

/* ---- 追加ボタン ---- */
.fab {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 1.9rem; box-shadow: 0 6px 18px rgba(79, 146, 105, .4);
}
.fab:hover { background: var(--accent-strong); }

/* ---- ダイアログ ---- */
dialog {
  width: min(460px, calc(100vw - 32px));
  border: none; border-radius: 24px; padding: 28px 24px 24px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
dialog::backdrop { background: rgba(20, 30, 25, .35); }
dialog h2 { margin: 0 0 20px; font-size: 1.2rem; }
form label { display: grid; gap: 6px; margin-bottom: 16px; font-size: .88rem; color: var(--muted); }
form label input { color: var(--text); background: var(--surface-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.spacer { flex: 1; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { background: var(--accent-strong); }
.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
