/* 献立 ― 見た目。スマホで使うことを前提に作り、PCでは中央に寄せて表示する */
:root {
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --sunken: #EFEBE2;
  --text: #24221E;
  --muted: #77726A;
  --line: #E2DDD2;
  --accent: #2F5D46;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3ECE6;
  --today: #B5532E;
  --danger: #B0362E;
  --star: #C98A0B;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1A17; --surface: #252420; --sunken: #2E2C27; --text: #EEEAE2; --muted: #A39D93; --line: #3A3832;
    --accent: #8FC2A6; --accent-ink: #14211A; --accent-soft: #263A2F; --today: #E58B66; --danger: #EE8178; --star: #E5B547;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
}
h1, h2, h3 { line-height: 1.35; margin: 0; font-weight: 700; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0; }
a { color: var(--accent); }
code { font-size: .85em; background: var(--sunken); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.page { max-width: 640px; margin: 0 auto; padding-inline: 16px; }

/* ---- 上の帯 ---- */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line);
}
.top-bar { max-width: 640px; margin: 0 auto; padding: 10px 16px 6px; display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.top-bar h1 { font-size: 1.2rem; }
.weeknav { max-width: 640px; margin: 0 auto; padding: 0 8px 8px; display: flex; align-items: center; justify-content: space-between; }
.weeknav .arrow { width: 44px; height: 40px; border: 0; background: none; color: var(--text); font-size: 1.5rem; cursor: pointer; border-radius: 8px; }
.weeknav .arrow:active { background: var(--sunken); }
.weeklabel { border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; }
.weeklabel small { font-weight: 400; color: var(--muted); font-size: .8rem; }

/* ---- 下のタブ ---- */
main.page { padding-top: 16px; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav button {
  flex: 1; max-width: 160px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .7rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; cursor: pointer;
}
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav button[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* ---- ボタン・入力 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; text-decoration: none;
}
.btn:active:not(:disabled) { background: var(--sunken); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:active:not(:disabled) { filter: brightness(.92); }
.btn.quiet { background: none; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn.danger { color: var(--danger); background: none; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.link { border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
input, select, textarea {
  font: inherit; font-size: 16px; /* 16px未満だと iPhone で拡大されてしまう */
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-height: 44px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.field > input, .field > select, .field > textarea { color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-msg { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }

/* ---- ログイン ---- */
.login { max-width: 400px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top, 0px)) 0 48px; }
.login .brand { font-size: 1.8rem; font-weight: 700; letter-spacing: .1em; }
.login .lead { color: var(--muted); margin: 4px 0 28px; }
.login h2 { margin-bottom: 12px; }
.login .or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; margin: 18px 0; }
.login .or::before, .login .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.login-links { display: flex; justify-content: center; gap: 20px; margin-top: 24px; font-size: .9rem; }

/* ---- 献立（日の一覧） ---- */
.make-btn { margin-bottom: 16px; }
.week-memo { font-size: .9rem; color: var(--muted); background: var(--sunken); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.daylist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.daylist li + li { border-top: 1px solid var(--line); }
.dayrow {
  width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: start; padding: 14px 14px 14px 12px; min-height: 72px;
}
.dayrow:active { background: var(--sunken); }
.dayrow .when { display: flex; flex-direction: column; align-items: center; line-height: 1.2; padding-top: 2px; }
.dayrow .dow { font-size: 1.15rem; font-weight: 700; }
.dayrow .date { font-size: .75rem; color: var(--muted); }
.dayrow.is-today .dow, .dayrow.is-today .date { color: var(--today); }
.dayrow.sun .dow { color: var(--today); }
.dayrow .menu { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dayrow .menu .dish { display: flex; gap: 8px; align-items: baseline; }
.dayrow .menu .dish.main { font-weight: 600; }
.dayrow .menu .dish:not(.main) { font-size: .9rem; }
.dayrow .menu .cat { font-size: .7rem; color: var(--muted); width: 2.4em; flex: none; }
.dayrow .menu .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dayrow .menu .new { font-size: .7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; flex: none; }
.dayrow .empty { color: var(--muted); padding-top: 2px; }
.dayrow .note { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.dayrow .tag { font-size: .7rem; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-top: 4px; white-space: nowrap; }
.dayrow.skip .menu { color: var(--muted); }

/* ---- 下から出る画面（シート） ---- */
dialog#sheet {
  border: 0; padding: 0; margin: 0 auto; background: var(--surface); color: var(--text);
  width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh;
  position: fixed; top: auto; bottom: 0; border-radius: 18px 18px 0 0;
}
dialog#sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
dialog#sheet::backdrop { background: rgba(20, 18, 14, .45); }
.sheet-body { padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; max-height: inherit; }
.sheet-body::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-size: 1.15rem; }
.sheet-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 4px 0; }
.switch-row small { display: block; color: var(--muted); font-size: .8rem; }
.inline-note { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: -6px; }
@media (min-width: 700px) {
  dialog#sheet { top: 50%; bottom: auto; transform: translateY(-50%); border-radius: 18px; width: calc(100% - 32px); }
  dialog#sheet[open] { animation: none; }
  .sheet-body::before { display: none; }
  .sheet-body { padding-top: 20px; }
}

/* ---- 買い物 ---- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.shoplist { list-style: none; margin: 0 0 20px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.shoplist:empty { display: none; }
.shoplist li { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.shoplist li + li { border-top: 1px solid var(--line); }
.shoplist label { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; cursor: pointer; }
.shoplist .item { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.shoplist .item small { color: var(--muted); font-size: .8rem; }
.shoplist li.done .item b { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.shoplist .x { border: 0; background: none; color: var(--muted); width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.section-title { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 0 4px 8px; }

/* ---- 料理一覧 ---- */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input { flex: 1; }
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem;
  border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.dishlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.dishlist li { display: flex; align-items: stretch; }
.dishlist li + li { border-top: 1px solid var(--line); }
.star { border: 0; background: none; width: 48px; font-size: 1.3rem; color: var(--line); cursor: pointer; flex: none; }
.star.on { color: var(--star); }
.dishrow { flex: 1; min-width: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; padding: 12px 14px 12px 0; cursor: pointer; display: flex; flex-direction: column; }
.dishrow:active { background: var(--sunken); }
.dishrow small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: .8rem; color: var(--muted); margin: 0 4px 8px; }
.selrow { display: flex; align-items: center; gap: 12px; width: 100%; padding-left: 14px; cursor: pointer; }
.selrow:active { background: var(--sunken); }
.selrow .dishrow { padding-left: 0; }
.bulkbar {
  position: fixed; left: 0; right: 0; z-index: 15; bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--line);
}
.bulkbar .btn { max-width: 608px; margin: 0 auto; display: flex; }
#dish-list:has(.bulkbar) { padding-bottom: 72px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---- 設定 ---- */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 14px; }
.group-title { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 0 4px 8px; }
.members { list-style: none; margin: 0; padding: 0; }
.members li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.members li + li { border-top: 1px solid var(--line); }
.members small { color: var(--muted); font-size: .8rem; margin-left: 6px; }
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper-row small { display: block; color: var(--muted); font-size: .8rem; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 48px; height: 44px; border: 0; background: var(--surface); color: var(--accent); font: inherit; font-size: 1.3rem; cursor: pointer; }
.stepper button:active:not(:disabled) { background: var(--sunken); }
.stepper button:disabled { color: var(--line); }
.stepper output { width: 40px; text-align: center; font-weight: 700; font-size: 1.05rem; border-inline: 1px solid var(--line); line-height: 44px; }

/* ---- 通知 ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: .9rem;
  max-width: calc(100vw - 32px); width: max-content;
}
.toast.error { background: var(--danger); color: #fff; }
