:root {
  --bg-start: #fff9ed;
  --bg-end: #f2efe8;
  --ink: #2d1a10;
  --muted: #6c5a4f;
  --card: #fffef9;
  --accent: #c2472c;
  --accent-2: #2f7a69;
  --ring: rgba(194, 71, 44, 0.25);
  --shadow: 0 10px 30px rgba(48, 30, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Bricolage Grotesque", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #ffe2b8 0%, transparent 42%),
    radial-gradient(circle at 90% 90%, #d4f0d9 0%, transparent 38%),
    linear-gradient(160deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
}

.page {
  width: min(1080px, 92vw);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.hero {
  background: color-mix(in srgb, var(--card) 88%, #ffd8c4 12%);
  border: 1px solid #ead8ca;
  border-radius: 22px;
  padding: 1.6rem 1.4rem;
  box-shadow: var(--shadow);
  animation: riseIn 460ms ease both;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 0.75rem;
}

h1,
h2 {
  font-family: "Literata", Georgia, serif;
}

h1 {
  margin: 0.45rem 0 0.5rem;
  line-height: 1.1;
  font-size: clamp(1.7rem, 4.2vw, 3rem);
}

.subtitle {
  margin: 0;
  max-width: 70ch;
  color: var(--muted);
}

.controls {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr 1fr 2fr;
  align-items: end;
  animation: riseIn 650ms ease both;
}

.controlsIngredients {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wideSearch {
  grid-column: span 3;
}

.subNav {
  margin-top: 1rem;
  display: flex;
  gap: 0.55rem;
}

.subNav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  border: 1px solid #d8c7b8;
  background: #fffdf8;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.subNav a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 12%, white 88%);
  border-color: color-mix(in srgb, var(--accent) 50%, #d8c7b8 50%);
}

.planner {
  margin-top: 1rem;
  background: color-mix(in srgb, var(--card) 90%, #d8efe8 10%);
  border: 1px solid #d4e2da;
  border-radius: 20px;
  padding: 1rem;
  box-shadow: var(--shadow);
  animation: riseIn 540ms ease both;
}

.plannerHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.plannerActions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.plannerHead h2 {
  margin: 0;
}

.plannerHelp {
  margin: 0.35rem 0 0.8rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.plannerStatus {
  margin: -0.45rem 0 0.7rem;
  min-height: 1.1em;
  color: #2d5f55;
  font-size: 0.82rem;
  font-weight: 700;
}

.plannerActionButton {
  min-height: 44px;
  border: 1px solid #d8c7b8;
  background: #fffdf8;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.plannerActionButton:hover {
  background: #f8f1e8;
}

.plannerActionButton:focus-visible {
  outline: 3px solid var(--ring);
}

.plannerGrid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
}

.dayColumn {
  background: #fffdfa;
  border: 1px solid #e6d8c8;
  border-radius: 14px;
  padding: 0.65rem;
  min-height: 220px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.55rem;
}

.dayColumn.isOver {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent-2) 35%, white 65%);
  background: #f4fcf8;
}

.dayTitle {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.dayList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  align-content: start;
}

.mealLanes {
  display: grid;
  gap: 0.45rem;
}

.mealLane {
  border: 1px dashed #dccdbf;
  border-radius: 10px;
  background: #fffefb;
  padding: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

.mealLane.isOver {
  border-color: var(--accent-2);
  background: #f4fcf8;
}

.mealLaneTitle {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6e5f53;
}

.mealLaneBreakfast {
  padding-top: 0.35rem;
}

.mealLaneToggle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  font: inherit;
  min-width: 0;
}

.mealLaneToggle .mealLaneTitle {
  min-width: 0;
  display: block;
}

.mealLaneBreakfast.isCollapsed {
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.mealLaneBreakfast.isCollapsed .mealLaneToggle {
  min-height: 1.3rem;
}

.mealLaneToggleIcon {
  font-size: 0.92rem;
  font-weight: 800;
  color: #5f4a3f;
  border: 1px solid #ddcdbf;
  border-radius: 999px;
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mealLaneToggle:focus-visible {
  outline: 3px solid var(--ring);
  border-radius: 7px;
}

.mealLaneBody {
  margin-top: 0.35rem;
}

.mealLaneBreakfast .mealLaneTitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dayRecipe {
  border: 1px solid #e7dccc;
  border-radius: 10px;
  background: #fff;
  padding: 0.45rem;
  display: grid;
  gap: 0.4rem;
}

.dayRecipeName {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.25;
  font-weight: 700;
}

.removePlanned {
  justify-self: start;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.removePlanned:hover {
  text-decoration: underline;
}

.dayHint {
  margin: 0;
  font-size: 0.78rem;
  color: #7a6a5f;
}

.clearDayButton {
  justify-self: start;
  border: 1px solid #ddcbbb;
  border-radius: 9px;
  background: #fffaf3;
  color: #5b4539;
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.clearDayButton:hover {
  background: #f6ecdf;
}

.clearDayButton:focus-visible {
  outline: 3px solid var(--ring);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid #d8c7b8;
  background: #fffdf8;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}

select:focus,
input:focus,
textarea:focus {
  outline: 3px solid var(--ring);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 3.1rem;
}

.metaBar {
  margin-top: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.grid {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid #e9d9ca;
  border-radius: 18px;
  padding: 0.95rem;
  box-shadow: 0 8px 24px rgba(60, 28, 16, 0.09);
  display: grid;
  gap: 0.55rem;
  transform: translateY(12px);
  opacity: 0;
  animation: reveal 420ms ease forwards;
}

.ateOutCard {
  background: linear-gradient(140deg, #fffdf8 0%, #f5f2ff 100%);
  border-color: #d6c7ee;
  box-shadow: 0 10px 26px rgba(76, 49, 118, 0.14);
}

.ateOutCard .recipeName {
  color: #4c3176;
}

.ateOutCard .tag {
  background: #f0e8ff;
  border-color: #d9c8f3;
  color: #4c3176;
}

.card[draggable="true"] {
  cursor: grab;
}

.card[draggable="true"]:active {
  cursor: grabbing;
}

.recipeName {
  font-size: 1.08rem;
  font-weight: 800;
}

.tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tag {
  background: #f7ede3;
  border: 1px solid #ebd6c3;
  color: #5a4538;
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
}

.sourceLink {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.sourceLink:hover {
  text-decoration: underline;
}

.listLinks {
  margin-top: 1.7rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed #d7c8bb;
  border-radius: 16px;
  padding: 1rem;
}

.listLinks ul {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
}

.listLinks a {
  color: #355d89;
}

.submitRecipe {
  margin-top: 1.2rem;
  background: color-mix(in srgb, var(--card) 90%, #f6e0cf 10%);
  border: 1px solid #e5d5c6;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.submitRecipe h2 {
  margin-top: 0;
}

.submitRecipe > p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.submitForm {
  display: grid;
  gap: 0.75rem;
}

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

.wideField {
  grid-column: span 2;
}

.pathPreview {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: #365c53;
}

.submitStatus {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.85rem;
  font-weight: 700;
  color: #3e534f;
}

.ingredientCard {
  align-content: start;
}

.matchedRow {
  display: grid;
  gap: 0.3rem;
}

.matchedLabel {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6f5b4f;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.matchedChips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.matchedChip {
  display: inline-flex;
  align-items: center;
  background: #fff3e3;
  border: 1px solid #f1d2ad;
  color: #6f3a1e;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.matchedChipMore {
  background: #f6efe7;
  border-color: #e3d6c8;
  color: #6f5b4f;
}

.ingredientPreview {
  display: grid;
  gap: 0.35rem;
}

.ingredientPreviewLabel {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: #5c483c;
}

.ingredientList {
  margin: 0;
  padding-left: 1.1rem;
  color: #4d3a2f;
  font-size: 0.88rem;
  display: grid;
  gap: 0.25rem 0.7rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ingredientListCompact {
  margin-bottom: 0.05rem;
}

.ingredientFull {
  background: #fffaf5;
  border: 1px solid #ecdac8;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
}

.ingredientListFull {
  grid-template-columns: 1fr;
}

.expandIngredients {
  justify-self: start;
  border: none;
  background: transparent;
  color: var(--accent-2);
  padding: 0;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.expandIngredients:hover {
  color: #225f52;
}

.expandIngredients:focus-visible {
  outline: 3px solid var(--ring);
  border-radius: 6px;
}

.ingredientSummary {
  margin: 0;
  font-size: 0.9rem;
  color: #4d3a2f;
}

.sourceContext {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sourceInfo {
  font-size: 0.74rem;
  font-weight: 700;
  color: #4c5c56;
  background: #e8f2ee;
  border: 1px solid #cde1da;
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
}

.sourceInfoEstimated {
  color: #7b4d18;
  background: #fff2df;
  border-color: #f0d1a9;
}

.ingredientDataStatus {
  margin: 0;
  font-size: 0.82rem;
  color: #5e6e67;
}

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

@keyframes riseIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes reveal {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 760px) {
  .page {
    padding-top: 1.2rem;
  }

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

  .plannerActions {
    width: 100%;
  }

  .plannerActionButton {
    flex: 1;
  }

  .plannerGrid {
    grid-template-columns: 1fr;
  }

  .dayColumn {
    min-height: 0;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .controlsIngredients {
    grid-template-columns: 1fr;
  }

  .wideSearch {
    grid-column: auto;
  }

  .submitGrid {
    grid-template-columns: 1fr;
  }

  .wideField {
    grid-column: auto;
  }

}

@media print {
  .hero,
  .controls,
  .metaBar,
  .grid,
  .listLinks,
  .submitRecipe,
  .plannerHelp,
  .plannerActions,
  .clearDayButton,
  .removePlanned,
  .dayHint {
    display: none !important;
  }

  .page {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .planner {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .plannerGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.siteFooter {
  margin-top: 4rem;
  padding: 1.5rem;
  border-top: 0.5px solid var(--color-border-tertiary);
  text-align: center;
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.siteFooter-nav {
  margin-bottom: 0.375rem;
}

.siteFooter-sources {
  font-size: 11px;
  color: var(--color-text-tertiary);
  line-height: 1.6;
}

.siteFooter-sources a {
  color: var(--color-text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.siteFooter-sources a:hover {
  color: var(--color-text-secondary);
}

.siteFooter a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.siteFooter a:hover {
  color: var(--color-text-primary);
  text-decoration: underline;
}

@media (max-width: 768px) {

  /* Page container — reduce horizontal padding */
  .page {
    padding: 0 1rem;
  }

  /* Hero section — tighter vertical spacing */
  .hero {
    padding: 1.5rem 0 1rem;
  }

  /* Hero h1 — scale down for mobile */
  .hero h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    line-height: 1.25;
  }

  /* subNav — wrap links on narrow screens */
  .subNav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .subNav a {
    font-size: 13px;
    padding: 0.3rem 0.7rem;
  }

  /* Recipe grid — single column on tablet */
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }

  /* Filter controls — stack vertically */
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .controls label {
    width: 100%;
  }

  .controls select,
  .controls input[type="search"] {
    width: 100%;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* metaBar */
  .metaBar {
    padding: 0.5rem 0;
  }

  /* Planner head — stack heading and actions */
  .plannerHead {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .plannerActions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .plannerActionButton {
    font-size: 13px;
    padding: 0.4rem 0.75rem;
  }

  /* Submit form grid — single column */
  .submitGrid {
    grid-template-columns: 1fr;
  }

  /* Submit form textarea — full width */
  .submitForm textarea,
  .submitForm input {
    font-size: 16px; /* prevents iOS zoom */
  }

  /* Site footer */
  .siteFooter {
    font-size: 11px;
    padding: 1rem;
    line-height: 1.7;
  }

  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px !important;
  }

}

@media (max-width: 480px) {

  /* Hero h1 — tighter on small phones */
  .hero h1 {
    font-size: 1.5rem;
  }

  /* Recipe grid — two columns minimum */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  /* subNav — smaller text */
  .subNav a {
    font-size: 12px;
    padding: 0.25rem 0.6rem;
  }

  .ingredientList {
    grid-template-columns: 1fr;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
