:root {
  --cream: #fff6df;
  --paper: #fffaf0;
  --yellow: #ffc62f;
  --purple: #8c6aae;
  --mint: #a8ddbc;
  --coral: #f06442;
  --ink: #090909;
  --muted: #5b5449;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --body: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--cream); }

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,198,47,.13), transparent 24%),
    radial-gradient(circle at 86% 32%, rgba(140,106,174,.1), transparent 28%),
    repeating-linear-gradient(7deg, rgba(9,9,9,.018) 0 1px, transparent 1px 5px),
    var(--cream);
  color: var(--ink);
  font: 16px/1.25 var(--body);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 4px solid var(--purple);
  outline-offset: 4px;
}

.app-shell {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 32px 8px 42px;
  text-align: center;
}

.topbar::before {
  position: absolute;
  z-index: -2;
  top: 94px;
  right: -14px;
  left: -14px;
  height: 118px;
  background: var(--purple);
  clip-path: polygon(0 8%, 12% 0, 18% 74%, 21% 66%, 24% 76%, 27% 66%, 30% 77%, 33% 67%, 36% 78%, 39% 68%, 42% 77%, 45% 67%, 48% 78%, 51% 68%, 54% 77%, 57% 67%, 60% 78%, 63% 68%, 66% 77%, 69% 67%, 72% 78%, 75% 68%, 78% 77%, 81% 67%, 84% 77%, 88% 70%, 100% 22%, 100% 91%, 50% 100%, 0 88%);
  content: "";
  filter: drop-shadow(0 6px 0 var(--ink));
}

.title-lockup { grid-column: 1 / -1; min-width: 0; }
.eyebrow {
  margin: 0 auto 28px;
  max-width: 620px;
  font-family: var(--display);
  font-size: clamp(2.2rem, 10vw, 5.3rem);
  line-height: .96;
  letter-spacing: .005em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--display); font-weight: 900; text-transform: uppercase; }
h1 {
  display: inline-block;
  margin: 0;
  padding: 10px 34px 12px;
  background: var(--ink);
  box-shadow: 0 8px 0 rgba(9,9,9,.25);
  color: var(--cream);
  font-size: clamp(3rem, 15vw, 6.5rem);
  line-height: .9;
  clip-path: polygon(3% 4%, 96% 0, 100% 91%, 48% 100%, 0 92%);
}
h2 { margin: 0; font-size: clamp(2rem, 8vw, 3.2rem); line-height: .95; }
h3 { margin: 0 0 10px; }

.brand-mark {
  position: absolute;
  top: 84px;
  right: -5px;
  z-index: -1;
  width: 74px;
  height: 106px;
  background: var(--coral);
  clip-path: polygon(35% 0, 100% 14%, 100% 88%, 30% 100%, 0 76%, 0 22%);
}
.brand-mark span { display: none; }

.accountbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.accountbar .small { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice {
  margin: 0 7px 20px;
  padding: 12px 15px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  box-shadow: 5px 6px 0 var(--ink);
  font-weight: 800;
  clip-path: polygon(2% 0, 98% 2%, 100% 88%, 96% 100%, 1% 96%, 0 12%);
}
.hidden { display: none !important; }

.date-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 0 8px 8px;
  padding: 13px;
  border: 3px solid var(--ink);
  background: var(--mint);
  box-shadow: 5px 6px 0 var(--ink);
  clip-path: polygon(2% 0, 98% 2%, 100% 88%, 96% 100%, 1% 96%, 0 12%);
}
.date-nav label { margin: 0; text-align: center; }
.date-nav input { margin-top: 6px; text-align: center; }
.date-nav button { min-width: 50px; padding-inline: 10px; font-size: 1.35rem; }
.date-nav button:disabled { cursor: default; opacity: .35; transform: none; }
.date-context { margin: 13px 10px 19px; font-weight: 900; text-align: center; text-transform: uppercase; }
.editing-note { display: inline-block; margin: 0 0 12px; padding: 6px 10px; background: var(--coral); font-weight: 900; text-transform: uppercase; transform: rotate(-1deg); }

.meal-grid { display: grid; gap: 18px; }
.card {
  position: relative;
  margin: 0 8px 22px;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  box-shadow: 7px 8px 0 var(--ink);
  clip-path: polygon(2% 0, 98% 1%, 100% 8%, 99% 94%, 96% 100%, 3% 98%, 0 92%, .5% 7%);
}

.meal-card { padding: 0; overflow: visible; }
.meal-card:nth-child(1) { background: var(--yellow); }
.meal-card:nth-child(2) { background: var(--purple); }
.meal-card:nth-child(3) { background: var(--mint); }
.meal-card:nth-child(4) { background: var(--coral); }
.meal-card summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 15px 18px;
  list-style: none;
  cursor: pointer;
}
.meal-card summary::-webkit-details-marker { display: none; }
.meal-card summary h2 {
  display: inline-block;
  justify-self: start;
  padding: 8px 13px;
  background: var(--ink);
  color: var(--cream);
  clip-path: polygon(5% 0, 95% 3%, 100% 18%, 97% 35%, 100% 51%, 96% 69%, 100% 88%, 92% 100%, 5% 96%, 0 82%, 4% 65%, 0 48%, 4% 27%, 0 10%);
}
.meal-card:not([open]) summary h2 { padding: 0; background: transparent; color: var(--ink); clip-path: none; }
.meal-toggle {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  background: var(--ink);
  color: var(--cream);
  font-size: 2.3rem;
  font-weight: 900;
  line-height: 1;
}
.meal-card[open] .meal-toggle { transform: rotate(45deg); }
.meal-card[open] summary { padding-bottom: 4px; }
.meal-body { padding: 10px 18px 20px; }

.summary-card h2 { margin-bottom: 16px; }
.summary-card { background: var(--paper); }

label {
  display: block;
  margin: 16px 0 7px;
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
}
input, textarea, select {
  width: 100%;
  min-height: 49px;
  padding: 11px 12px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
  clip-path: polygon(1% 0, 99% 1%, 100% 88%, 97% 100%, 1% 96%, 0 10%);
}
textarea { min-height: 88px; resize: vertical; }

button, label.secondary {
  min-height: 45px;
  padding: 9px 15px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--cream);
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 3px 4px 0 var(--ink);
  clip-path: polygon(8% 0, 92% 2%, 100% 22%, 97% 83%, 90% 100%, 7% 96%, 0 78%, 2% 18%);
}
button:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
button.secondary, label.secondary { background: var(--coral); color: var(--ink); }
button.ghost { background: var(--paper); color: var(--ink); }
button.danger { background: var(--coral); color: var(--ink); }
.meal-body .row button:first-child { background: var(--mint); color: var(--ink); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: stretch; }
.split button { min-width: 70px; }
.row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 15px 0; }
.chip {
  min-height: 38px;
  padding: 7px 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
  font-size: .9rem;
  font-weight: 800;
  text-transform: lowercase;
  clip-path: polygon(9% 0, 91% 0, 100% 24%, 97% 78%, 88% 100%, 10% 96%, 0 75%, 2% 21%);
}
span.chip { display: inline-flex; align-items: center; gap: 5px; }
.chip .ghost { min-height: 0; padding: 0 2px; border: 0; background: transparent; box-shadow: none; clip-path: none; font-size: 1rem; }
.chip.pinned { background: var(--mint); }

.list { display: grid; gap: 12px; }
.item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding-top: 13px; border-top: 2px dashed var(--ink); }
.item:first-child { border-top: 0; padding-top: 0; }
.item-actions { display: flex; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.item-actions button { min-height: 38px; padding: 6px 10px; }
.foodline { font-weight: 900; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .82rem; }
.severity { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.severity button { background: var(--paper); color: var(--ink); }
.severity button.active { background: var(--purple); color: var(--ink); }

.tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 7px 5px calc(5px + env(safe-area-inset-bottom));
  background: var(--ink);
  clip-path: polygon(0 10%, 3% 0, 6% 11%, 9% 0, 12% 11%, 15% 0, 18% 11%, 21% 0, 24% 11%, 27% 0, 30% 11%, 33% 0, 36% 11%, 39% 0, 42% 11%, 45% 0, 48% 11%, 51% 0, 54% 11%, 57% 0, 60% 11%, 63% 0, 66% 11%, 69% 0, 72% 11%, 75% 0, 78% 11%, 81% 0, 84% 11%, 87% 0, 90% 11%, 93% 0, 96% 11%, 100% 1%, 100% 100%, 0 100%);
}
.tabs button {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 69px;
  place-content: center;
  padding: 8px 2px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--cream);
  font-size: clamp(.64rem, 2.7vw, .9rem);
  clip-path: none;
}
.tabs button span { font-size: 1.45rem; line-height: 1; }
.tabs button.active { background: var(--yellow); color: var(--ink); clip-path: polygon(12% 0, 88% 2%, 100% 18%, 94% 100%, 8% 95%, 0 16%); }
.auth-only { display: none; }

@media (min-width: 680px) {
  .app-shell { padding-inline: 26px; }
  .topbar { padding-top: 42px; }
  .meal-grid { grid-template-columns: 1fr 1fr; }
  .meal-card:first-child { grid-column: 1 / -1; }
  .summary-card { padding: 22px; }
}

@media (max-width: 430px) {
  .date-nav { grid-template-columns: 46px minmax(0, 1fr) 46px; padding-inline: 9px; }
  .date-nav button { min-width: 0; }
  .item { flex-direction: column; }
  .item-actions { width: 100%; }
  .item-actions button { flex: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: paste-in .28s both; }
  .meal-card:nth-child(2) { animation-delay: .04s; }
  .meal-card:nth-child(3) { animation-delay: .08s; }
  .meal-card:nth-child(4) { animation-delay: .12s; }
  @keyframes paste-in { from { opacity: 0; transform: translateY(12px) rotate(-.4deg); } }
}
