:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b716d;
  --line: #e4e2db;
  --accent: #2f7d4f;
  --accent-soft: #e5f2ea;
  --warn: #c2410c;
  --warn-soft: #fdebe1;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --card: #1d211f;
    --text: #e8ebe9;
    --muted: #9aa29d;
    --line: #2e3431;
    --accent: #5cc189;
    --accent-soft: #1f3529;
    --warn: #fb923c;
    --warn-soft: #3a2418;
    --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", "Meiryo", sans-serif;
  line-height: 1.6;
  font-size: 15px;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.top h1 { font-size: 18px; margin: 0; white-space: nowrap; }
.top select { width: auto; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }
h2 { font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 15px; margin: 0; }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-size: 13px; flex: none; }

.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.grid3 > :last-child { grid-column: 1 / -1; }
label, .lbl { font-size: 13px; color: var(--muted); display: block; }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; margin-top: 4px;
}
.money { display: flex; align-items: center; gap: 6px; }
.money span { font-weight: 600; color: var(--text); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; font-size: 13px; font: inherit; font-size: 13px;
}
.chip input { display: none; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

button { font: inherit; cursor: pointer; }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 600; width: 100%; }
.primary:hover { filter: brightness(1.05); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }

.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.small { font-size: 12px; }
.meta { color: var(--muted); font-size: 12.5px; }

/* 予算 */
.budget { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.budget.over { background: var(--warn-soft); }
.budget-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.bar { height: 8px; background: var(--card); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar div { height: 100%; background: var(--accent); }
.over .bar div { background: var(--warn); }

/* シフト表 */
.shift { margin-bottom: 16px; }
.shift .table-wrap { margin-top: 6px; }
.shift-grid th, .shift-grid td { text-align: center; padding: 6px 4px; }
.shift-grid tbody th { text-align: left; padding-left: 10px; background: var(--card); font-size: 13px; }
.shift-grid input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.day-btn { background: none; border: 0; font-weight: 700; color: var(--text); padding: 2px 6px; border-radius: 6px; }
.day-btn:hover { background: var(--accent-soft); }

/* 献立 */
.menu { list-style: none; margin: 0; padding: 0; }
.day { padding: 14px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.day-label { width: 34px; height: 34px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; flex: none; }
.day.off .day-label { opacity: .5; }
.meals { display: grid; gap: 6px; }
.meal { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.meal.skipped { opacity: .6; align-items: center; }
.meal-tag { font-size: 12px; color: var(--muted); width: 44px; flex: none; padding-top: 2px; white-space: nowrap; }
.meal-body { flex: 1; min-width: 0; }
.meal-actions { display: flex; gap: 4px; flex: none; }
.day-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.emoji { font-size: 18px; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 4px; }
.ings { font-size: 13px; color: var(--muted); margin: 6px 0; }
.steps { margin: 4px 0 0; padding-left: 20px; font-size: 13.5px; }

/* 買い物リスト */
.cat { font-size: 13px; color: var(--muted); margin: 16px 0 4px; }
.shop { list-style: none; padding: 0; margin: 0; }
.shop li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.nm { font-weight: 500; }
#haveBox { margin-top: 16px; }

/* 比較 */
.rec { border: 2px solid var(--accent); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.rec-label { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .05em; }
.rec-main { font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0; }
.rec-split { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.rec-split .meta i { margin-right: 2px; }
.tag { font-size: 10.5px; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 2px; color: var(--muted); }
.store-card.market { border-style: dashed; }
.store-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.store-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.store-card.best { border-color: var(--accent); background: var(--accent-soft); }
.sc-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.sc-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.table-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.switch { display: flex; align-items: center; gap: 6px; color: var(--text); }
.switch input { width: auto; margin: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
th { background: var(--bg); font-weight: 600; font-size: 12px; }
th i { margin-right: 4px; }
td.min { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
td.na { color: var(--muted); }
.sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
tfoot td { font-weight: 700; border-bottom: 0; }
.price-in { width: 72px; padding: 4px 6px; margin: 0; text-align: right; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: .25s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .grid3 { grid-template-columns: 160px 120px 1fr; }
  .grid3 > :last-child { grid-column: auto; }
}
.fruit-opt { margin: 0 0 14px; font-size: 14px; }
.fruit { padding: 6px 10px 0 64px; }

/* 現在地 */
.loc { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.loc select { width: auto; margin: 0; padding: 6px 8px; }
#locStatus { margin-top: 4px; }
.dist { font-size: 11px; color: var(--muted); margin-left: 2px; }

/* 特売 */
.specials { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.specials .chips a { text-decoration: none; color: var(--text); }
.special-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.special-form > * { margin: 0; }
.special-form input, .special-form select { margin: 0; }
.special-list { list-style: none; padding: 0; margin: 10px 0 0; }
.special-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.sale { display: block; font-size: 10.5px; color: var(--warn); font-weight: 700; }
@media (min-width: 640px) {
  .special-form { grid-template-columns: 2fr 1.3fr 1fr 1.2fr auto; }
}
.sp-label { display: block; font-size: 12px; }
