:root {
  color-scheme: light;
  --bg: #fbf5ea;
  --paper: #fffaf1;
  --paper-strong: #ffffff;
  --text: #3f342b;
  --muted: #7c7064;
  --line: #e6d7c2;
  --green: #5f9f7a;
  --green-dark: #3f765a;
  --rose: #eaa3a1;
  --peach: #f4bd82;
  --yellow: #f5dc83;
  --mint: #a7d8b9;
  --sky: #9fc7e8;
  --lavender: #c8b7df;
  --red: #b84a3a;
  --shadow: 0 16px 28px rgba(96, 76, 52, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(95, 159, 122, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(95, 159, 122, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto;
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 16px;
  background: linear-gradient(90deg, var(--rose), var(--peach), var(--yellow), var(--mint), var(--sky), var(--lavender));
  pointer-events: none;
  z-index: 20;
}

a {
  color: var(--green-dark);
}

img {
  max-width: 100%;
  display: block;
}

input,
select,
textarea,
button,
.button {
  font: inherit;
  border-radius: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--text);
  padding: 0.72rem 0.78rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--green-dark);
  background: var(--paper-strong);
  color: var(--green-dark);
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
  font-weight: 750;
  box-shadow: 0 3px 0 rgba(63, 52, 43, 0.12);
  min-width: 0;
}

button.primary,
.button.primary {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
}

.link-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.52rem 0.8rem;
  box-shadow: none;
  font-weight: 750;
}

button.danger {
  border-color: var(--red);
  color: var(--red);
}

.button.ghost {
  border-color: var(--line);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  min-height: 82px;
  padding: 1.1rem clamp(1rem, 3vw, 2rem) 0.75rem;
  background: rgba(255, 250, 241, 0.94);
  border-bottom: 2px dashed var(--line);
  backdrop-filter: blur(12px);
  max-width: 100%;
  overflow: hidden;
}

.topbar > * {
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 900;
  font-size: 1.18rem;
}

.brand img {
  width: 44px;
  height: 44px;
}

.menu-toggle {
  display: none;
}

.menu-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.nav {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
}

.nav a,
.account a {
  color: var(--text);
  text-decoration: none;
  padding: 0.52rem 0.8rem;
  border-radius: 8px;
  font-weight: 750;
}

.nav a.active {
  background: var(--yellow);
  color: var(--text);
  box-shadow: 0 3px 0 rgba(63, 52, 43, 0.12);
}

.account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.shell {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.flash.success {
  border-color: var(--mint);
}

.flash.error {
  border-color: #d67b70;
}

.auth-grid {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px);
  align-items: center;
  gap: clamp(1.5rem, 4vw, 4rem);
}

.auth-copy {
  position: relative;
  padding-top: 12.5rem;
}

.auth-copy::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: min(340px, 76vw);
  aspect-ratio: 2 / 1;
  border-radius: 180px 180px 0 0;
  border-top: 20px solid var(--rose);
  border-left: 20px solid var(--rose);
  border-right: 20px solid var(--rose);
  box-shadow:
    inset 0 20px 0 var(--peach),
    inset 0 40px 0 var(--yellow),
    inset 0 60px 0 var(--mint),
    inset 0 80px 0 var(--sky);
}

.auth-copy h1,
.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  font-weight: 900;
}

.auth-copy p {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.15rem;
}

.panel {
  background:
    linear-gradient(transparent 31px, rgba(234, 163, 161, 0.16) 32px),
    var(--paper);
  background-size: 100% 32px, auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: var(--shadow);
}

.auth-form,
.recipe-form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 750;
}

.small,
.eyebrow,
.meta,
.tags {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
  font-weight: 900;
}

.page-head {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: rgba(255, 250, 241, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-head::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 28px;
  width: 62px;
  height: 20px;
  border-radius: 8px;
  background: var(--peach);
  transform: rotate(-2deg);
  box-shadow: 0 2px 0 rgba(63, 52, 43, 0.12);
}

.actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.quick-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-hero::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 28px;
  width: 62px;
  height: 20px;
  border-radius: 8px;
  background: var(--mint);
  transform: rotate(-2deg);
  box-shadow: 0 2px 0 rgba(63, 52, 43, 0.12);
}

.quick-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 1.05;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: end;
}

.quick-list {
  display: grid;
  gap: 0.85rem;
}

.quick-day {
  position: relative;
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.quick-day::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 10px;
  background: var(--rose);
}

.quick-day:nth-child(6n + 2)::before {
  background: var(--peach);
}

.quick-day:nth-child(6n + 3)::before {
  background: var(--yellow);
}

.quick-day:nth-child(6n + 4)::before {
  background: var(--mint);
}

.quick-day:nth-child(6n + 5)::before {
  background: var(--sky);
}

.quick-day:nth-child(6n)::before {
  background: var(--lavender);
}

.quick-day > header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding-left: 0.55rem;
  font-weight: 900;
  font-size: 1.1rem;
}

.quick-day > header span {
  font-size: 1.35rem;
}

.quick-meals {
  display: grid;
  gap: 0.65rem;
  padding-left: 0.55rem;
}

.quick-meal {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "slot"
    "image"
    "text";
  gap: 0.65rem;
  align-items: start;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.quick-photo {
  grid-area: image;
  width: min(100%, 230px);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background-color: #f2e7d7;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  border: 1px solid var(--line);
}

.quick-meal strong {
  display: block;
  min-width: 0;
  font-size: 1.08rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.quick-meal-content {
  grid-area: text;
  min-width: 0;
}

.quick-meal p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.quick-slot {
  grid-area: slot;
  width: max-content;
  max-width: 100%;
  padding: 0.22rem 0.55rem;
  background: var(--yellow);
  border-radius: 8px;
  font-weight: 850;
}

.quick-meal:nth-child(2n) .quick-slot {
  background: var(--sky);
}

.empty-state {
  display: grid;
  gap: 0.8rem;
  max-width: 620px;
  padding: 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-state h2 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2.2rem);
  line-height: 1.1;
}

.empty-state .button {
  width: max-content;
  max-width: 100%;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(190px, 1fr));
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.5rem 0.1rem 0.8rem;
}

.day-column {
  min-width: 190px;
  position: relative;
  padding-top: 0.65rem;
}

.day-column::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 34px;
  height: 18px;
  border-radius: 5px;
  background: #d6b16f;
  transform: translateX(-50%);
  box-shadow: inset 0 -3px 0 rgba(63, 52, 43, 0.13);
  z-index: 1;
}

.day-column > header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  padding: 0.7rem 0.75rem;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 900;
}

.day-column:nth-child(7n + 1) > header {
  border-top: 8px solid var(--rose);
}

.day-column:nth-child(7n + 2) > header {
  border-top: 8px solid var(--peach);
}

.day-column:nth-child(7n + 3) > header {
  border-top: 8px solid var(--yellow);
}

.day-column:nth-child(7n + 4) > header {
  border-top: 8px solid var(--mint);
}

.day-column:nth-child(7n + 5) > header {
  border-top: 8px solid var(--sky);
}

.day-column:nth-child(7n + 6) > header {
  border-top: 8px solid var(--lavender);
}

.day-column:nth-child(7n) > header {
  border-top: 8px solid #f1b4cf;
}

.meal-card {
  display: grid;
  gap: 0.65rem;
  min-height: 340px;
  margin-bottom: 0.85rem;
  padding: 0.8rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 18px rgba(96, 76, 52, 0.1);
}

.meal-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.meal-title h3 {
  margin: 0;
  display: inline-flex;
  padding: 0.22rem 0.55rem;
  background: var(--mint);
  border-radius: 8px;
  font-size: 1rem;
}

.meal-card:nth-of-type(3n) .meal-title h3 {
  background: var(--yellow);
}

.meal-card:nth-of-type(3n + 1) .meal-title h3 {
  background: var(--sky);
}

.icon-button {
  min-height: 32px;
  width: 32px;
  padding: 0;
  border-color: var(--line);
  color: var(--red);
}

.planned {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.planned img {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

.planned p {
  margin: 0;
  color: var(--muted);
}

.compact-form {
  display: grid;
  gap: 0.45rem;
}

.compact-form input,
.compact-form select {
  min-height: 38px;
  padding: 0.5rem;
}

.suggestions summary {
  cursor: pointer;
  color: var(--green-dark);
  font-weight: 850;
}

.suggestion-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.45rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
}

.suggestion-row img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.suggestion-row button {
  min-height: 34px;
  width: 34px;
  padding: 0;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 260px) auto;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.recipe-card {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.recipe-card > img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-bottom: 8px solid var(--yellow);
}

.recipe-card:nth-child(6n + 1) > img {
  border-bottom-color: var(--rose);
}

.recipe-card:nth-child(6n + 2) > img {
  border-bottom-color: var(--peach);
}

.recipe-card:nth-child(6n + 3) > img {
  border-bottom-color: var(--yellow);
}

.recipe-card:nth-child(6n + 4) > img {
  border-bottom-color: var(--mint);
}

.recipe-card:nth-child(6n + 5) > img {
  border-bottom-color: var(--sky);
}

.recipe-card:nth-child(6n) > img {
  border-bottom-color: var(--lavender);
}

.recipe-card > div {
  padding: 1rem;
}

.recipe-card h2 {
  margin: 0.2rem 0 0.4rem;
}

.recipe-card h2 a {
  color: var(--text);
  text-decoration: none;
}

.meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.meta span {
  padding: 0.25rem 0.45rem;
  background: #f2e7d7;
  border-radius: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 1rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.check input {
  width: auto;
}

.current-photo {
  width: min(420px, 100%);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.code-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.code-list code {
  padding: 0.5rem 0.65rem;
  background: #f2e7d7;
  border-radius: 8px;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(0, auto) auto;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    min-height: 0;
    overflow: visible;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    background: var(--paper-strong);
    border-color: var(--line);
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
  }

  .menu-toggle span {
    display: block;
  }

  .menu-panel {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .menu-panel.open {
    display: grid;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 0.3rem;
    width: 100%;
    min-width: 0;
  }

  .nav a {
    text-align: center;
    padding: 0.5rem 0.35rem;
    font-size: 0.92rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.6rem;
    justify-content: stretch;
    white-space: normal;
    width: 100%;
    min-width: 0;
  }

  .account a {
    justify-self: start;
    padding-left: 0;
  }

  .auth-grid,
  .two-column,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-copy {
    padding-top: 10.5rem;
  }

  .page-head {
    align-items: start;
    flex-direction: column;
  }

  .quick-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .quick-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .shell {
    width: min(100% - 1rem, 1440px);
    padding-top: 1rem;
  }

  .brand {
    font-size: 1rem;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .auth-copy {
    padding-top: 12rem;
  }

  .auth-copy::before {
    width: min(270px, 84vw);
    border-top-width: 16px;
    border-left-width: 16px;
    border-right-width: 16px;
    box-shadow:
      inset 0 16px 0 var(--peach),
      inset 0 32px 0 var(--yellow),
      inset 0 48px 0 var(--mint),
      inset 0 64px 0 var(--sky);
  }

  .account {
    font-size: 0.9rem;
    gap: 0.4rem;
  }

  .account span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav a {
    font-size: 0.82rem;
    padding: 0.45rem 0.2rem;
  }

  .quick-hero,
  .quick-day,
  .empty-state {
    padding: 0.8rem;
  }

  .quick-meal {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
  }

  .quick-photo {
    width: min(100%, 210px);
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }
}
