:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64706a;
  --line: #d8ddd8;
  --paper: #f7f8f4;
  --panel: #ffffff;
  --panel-2: #eef5ef;
  --basil: #2f6f4e;
  --basil-dark: #1d4f38;
  --tomato: #b94834;
  --corn: #d69b2d;
  --blue: #356f96;
  --shadow: 0 18px 44px rgba(30, 45, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 111, 78, 0.08), transparent 38%),
    linear-gradient(225deg, rgba(180, 72, 52, 0.07), transparent 42%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--basil);
}

#app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--tomato);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.9rem;
  letter-spacing: 0;
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-stats span,
.badge,
.recipe-id {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-stats strong {
  color: var(--basil-dark);
  margin-right: 4px;
}

.tabs,
.toolbar,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -24px 18px;
  padding: 10px 24px;
  background: rgba(247, 248, 244, 0.88);
  backdrop-filter: blur(16px);
  border-block: 1px solid rgba(216, 221, 216, 0.7);
}

.tabs button,
.segmented button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.tabs button.active,
.segmented button.active {
  background: var(--basil);
  border-color: var(--basil);
  color: white;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.recipe-toolbar {
  justify-content: start;
}

.search,
select,
table input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
}

.search {
  width: min(360px, 100%);
}

.toggle {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 800;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.split-layout > *,
.planner-layout > *,
.shop-layout > *,
.pantry-layout > * {
  min-width: 0;
}

.week-grid,
.recipe-list,
.pantry-grid {
  display: grid;
  gap: 10px;
  min-width: 0;
}

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

.recipe-list {
  max-height: calc(100vh - 174px);
  overflow: auto;
  padding-right: 4px;
}

.meal-card,
.recipe-card,
.pantry-card,
.detail,
.custom-table-panel,
.shop-panel,
.shop-group,
.ingredient-table,
.meal-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.meal-card,
.recipe-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 178px;
  padding: 16px;
  text-align: left;
}

.recipe-card {
  min-height: 126px;
  box-shadow: none;
}

.recipe-card.selected {
  border-color: var(--basil);
  background: var(--panel-2);
}

.meal-card.optional {
  border-style: dashed;
}

.day {
  color: var(--tomato);
  font-weight: 900;
}

.meal-card strong,
.recipe-card strong,
.custom-day strong {
  font-size: 1.05rem;
  line-height: 1.18;
}

.meal-meta,
.tip,
.recipe-card span,
.custom-day small,
.pantry-card small,
.shop-row small {
  color: var(--muted);
}

.tip {
  min-height: 42px;
  font-size: 0.88rem;
  line-height: 1.35;
}

.mini-badges,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  min-height: 24px;
  background: #edf4ed;
  color: var(--basil-dark);
}

.badge.warm {
  background: #fff6e2;
  color: #8b5d0d;
}

.badge.blue {
  background: #edf5fa;
  color: var(--blue);
}

.recipe-id {
  width: fit-content;
  min-height: 24px;
  background: #f3eee7;
  color: #684934;
}

.detail {
  padding: 18px;
  min-width: 0;
}

.detail.empty {
  min-height: 320px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.detail-head h2 {
  margin: 8px 0 6px;
  font-size: clamp(1.5rem, 2.6vw, 2.6rem);
  line-height: 1;
}

.time-stack {
  display: grid;
  place-items: center;
  min-width: 92px;
  height: 92px;
  border-radius: 8px;
  background: var(--basil);
  color: white;
}

.time-stack strong {
  font-size: 2rem;
  line-height: 1;
}

.time-stack span {
  font-size: 0.75rem;
  font-weight: 800;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.note-grid article,
.custom-day {
  border-radius: 8px;
  padding: 12px;
  background: #f7faf7;
  border: 1px solid var(--line);
}

.note-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 18px;
}

.ingredient-list,
.step-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li,
.step-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.4;
}

.step-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
}

.step-list span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--tomato);
  color: white;
  font-size: 0.8rem;
  font-weight: 900;
}

.planner-layout,
.shop-layout,
.pantry-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.custom-table-panel,
.shop-panel,
.ingredient-table,
.meal-strip {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--basil-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td select,
td input {
  width: 100%;
}

.custom-days {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.custom-day {
  display: grid;
  gap: 6px;
  min-height: 126px;
}

.custom-day span {
  color: var(--tomato);
  font-weight: 900;
}

.shop-list,
.shop-panel {
  display: grid;
  gap: 12px;
}

.shop-group {
  box-shadow: none;
  padding: 12px;
}

.shop-group h3 {
  color: var(--basil-dark);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.shop-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid #edf0ed;
}

.shop-row:last-child {
  border-bottom: 0;
}

.shop-row span {
  display: grid;
  gap: 3px;
}

.shop-row.done {
  opacity: 0.48;
}

.shop-row.done strong {
  text-decoration: line-through;
}

.meal-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  box-shadow: none;
}

.mini-meal {
  display: grid;
  gap: 4px;
  min-height: 88px;
  padding: 12px;
  text-align: left;
  box-shadow: none;
}

.mini-meal span {
  color: var(--tomato);
  font-weight: 900;
}

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

.pantry-card {
  min-height: 150px;
  padding: 14px;
  box-shadow: none;
}

.pantry-card p {
  color: var(--ink);
  line-height: 1.42;
}

@media (max-width: 1100px) {
  .split-layout,
  .planner-layout,
  .shop-layout,
  .pantry-layout {
    grid-template-columns: 1fr;
  }

  .recipe-list {
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  #app {
    padding: 14px;
  }

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

  .header-stats {
    justify-content: start;
  }

  .tabs {
    margin-inline: -14px;
    padding-inline: 14px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tabs button {
    flex: 0 0 auto;
  }

  .week-grid,
  .recipe-list,
  .note-grid,
  .recipe-columns,
  .custom-days,
  .meal-strip,
  .pantry-grid {
    grid-template-columns: 1fr;
  }

  .detail-head {
    flex-direction: column;
  }

  .time-stack {
    width: 100%;
    height: 74px;
  }
}

@media print {
  body {
    background: white;
  }

  #app {
    padding: 0;
  }

  .app-header,
  .tabs,
  .toolbar,
  .meal-strip,
  .custom-table-panel,
  .detail,
  .recipe-list,
  .week-grid,
  .pantry-grid,
  .ingredient-table {
    display: none !important;
  }

  .shop-layout,
  .planner-layout,
  .pantry-layout {
    display: block;
  }

  .shop-panel,
  .shop-group,
  .shop-list {
    box-shadow: none;
    border: 0;
  }

  .shop-group {
    break-inside: avoid;
  }
}
