:root {
  --accent: #99451B;
  --tint: #F5E4D5;
  --page: #FAF6F1;
  --surface: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #4D4D4D;
  --border: #737373;
  --error: #A71926;
  --sunday: #A71926;
  --saturday: #184C9D;
  --space: 8px;
  --content: 760px;
  --nav-height: calc(72px + env(safe-area-inset-bottom));
  scroll-padding-bottom: calc(var(--nav-height) + var(--space));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  overflow-wrap: anywhere;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.35; }
h2 { font-size: 20px; line-height: 1.4; }
h3 { font-size: 16px; }

.site-header {
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header-inner, main, .nav-inner {
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.header-inner, .section-heading, .save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

.header-inner { padding-block: 16px; }
#period { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }
#advance { flex-shrink: 0; }
main { padding-top: var(--space); padding-bottom: calc(var(--nav-height) + 24px); }
.save-bar { min-height: 48px; margin-bottom: var(--space); }
#save-status, .empty, #pending-count { color: var(--muted); }
#save-status[data-error], #dialog-error { color: var(--error); }
.section-heading { flex-wrap: wrap; }
.section-heading, #meals-title { margin-bottom: 16px; }

.days, .groups { display: grid; gap: var(--space); }
.card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.day label, label[for="item-name"], label[for="edit-name"], legend { font-weight: 700; }
.sunday { color: var(--sunday); }
.saturday { color: var(--saturday); }
.prep, .groups { margin-top: 16px; }

button, input, textarea { font: inherit; }
input[type="text"], textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: var(--space);
  padding: 8px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
button {
  min-height: 48px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: var(--surface);
  font-weight: 700;
  cursor: pointer;
}
button.secondary { background: var(--surface); color: var(--accent); }
button.danger { background: var(--error); border-color: var(--error); }
button:disabled { cursor: default; color: var(--muted); border-color: var(--border); background: var(--page); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

fieldset { min-inline-size: 0; border: 0; padding: 0; margin: 16px 0; }
legend { padding: 0; }
.category-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space); }
.choice, .item-check { display: flex; align-items: center; gap: var(--space); min-height: 48px; cursor: pointer; }
.choice { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; }
.choice:has(:checked) { background: var(--tint); border-color: var(--accent); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 20px; height: 20px; margin: 0; flex: none; }
#add-item > button { width: 100%; }
.empty { margin-top: var(--space); }
.items { padding: 0; margin: 0; list-style: none; }
.item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  border-top: 1px solid var(--border);
  padding-block: var(--space);
}
.item:first-child { margin-top: var(--space); }
.item:last-child { padding-bottom: 0; }
.item-check { flex: 1 1 140px; min-width: 0; }
.item-check input:checked + span { text-decoration: line-through; color: var(--muted); }
.item-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space); }
.item-actions button { padding-inline: 8px; }

.bottom-nav {
  position: fixed;
  inset: auto 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space); padding-block: 8px; }
.nav-inner button { min-width: 0; background: var(--surface); color: var(--ink); border-color: transparent; }
.nav-inner [aria-current] { background: var(--tint); color: var(--accent); border-color: var(--accent); }
dialog {
  color: var(--ink);
  width: min(440px, calc(100% - 32px));
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
dialog::backdrop { background: rgb(26 26 26 / 55%); }
#dialog-description { margin-block: var(--space) 16px; white-space: pre-line; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }
@media (min-width: 700px) {
  .days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  dialog .category-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
