:root {
  --ink: #17231e;
  --muted: #61706a;
  --paper: #f6f4ed;
  --line: #e1ddd0;
  --soft-line: #eee9dd;
  --panel: #fffdf7;
  --leaf: #5f8f55;
  --gold: #d99c3a;
  --sea: #4e89a9;
  --berry: #9b4f68;
  --mint: #eef7ef;
  --cream: #fff8e8;
  --sky: #edf7fb;
  --rose: #fbf0f3;
  --shadow: 0 18px 45px rgba(36, 46, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 420px),
    var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="number"],
input[type="text"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

button {
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #9f9a87;
  background: #f7f3e8;
}

.app-hero {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.app-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 23, 18, 0.74), rgba(12, 23, 18, 0.38), rgba(12, 23, 18, 0.12));
}

.hero-content {
  position: relative;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
  color: #fff;
}

.hero-content h1 {
  margin: 6px 0 10px;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1;
  letter-spacing: 0;
}

.hero-content p {
  max-width: 740px;
  margin: 0;
  font-size: 18px;
}

.kicker {
  margin: 0 0 6px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  opacity: 0.78;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 22px auto 56px;
}

.toolbar,
.setup-panel,
.people-panel,
.cookbook-panel,
.guidance-grid,
.shopping-panel,
.poster {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

[hidden] {
  display: none !important;
}

.setup-panel {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 18px;
  align-items: end;
  margin-top: 16px;
  padding: 18px;
}

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

.setup-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.control-group {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.control-group label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 0 12px;
}

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

.member-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.people-panel,
.cookbook-panel,
.poster,
.shopping-panel {
  margin-top: 16px;
  padding: 18px;
}

.people-panel summary,
.cookbook-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.people-panel summary::-webkit-details-marker,
.cookbook-panel summary::-webkit-details-marker {
  display: none;
}

.people-panel summary::after,
.cookbook-panel summary::after {
  content: "展开";
  min-width: 54px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.people-panel[open] summary::after,
.cookbook-panel[open] summary::after {
  content: "收起";
}

.people-panel summary small,
.cookbook-panel summary small {
  color: var(--muted);
  font-weight: 700;
}

.people-panel .section-head,
.cookbook-panel .section-head {
  margin-top: 16px;
}

.section-head,
.poster-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.section-head p,
.poster-head p {
  margin: 0;
  color: var(--muted);
}

h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.person-card {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.person-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.person-card.custom {
  border-color: #c7d7e4;
  background: #f6fbff;
}

.person-card strong {
  font-size: 15px;
}

.person-card p,
.field-label {
  display: grid;
  gap: 5px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.person-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.person-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--leaf);
}

.person-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}

.person-controls button {
  min-height: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.remove-person {
  min-height: 32px;
  padding: 0 10px;
  color: #8a3d45;
  background: #fff7f7;
}

.cookbook-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cookbook-actions select {
  width: min(260px, 100%);
}

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

.cookbook-card {
  display: grid;
  grid-template-columns: 18px 42px 1fr;
  gap: 9px;
  align-items: start;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--panel);
  padding: 11px;
}

.cookbook-card input {
  margin-top: 4px;
  accent-color: var(--leaf);
}

.cookbook-card .score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 8px;
  background: #e8f4ec;
  color: #2f7142;
  font-weight: 800;
}

.cookbook-card strong,
.cookbook-card small {
  display: block;
}

.cookbook-card strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.cookbook-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.guidance-grid {
  display: grid;
  grid-template-columns: 1fr 1.55fr;
  margin-top: 16px;
}

.guidance-grid article {
  padding: 18px;
}

.guidance-grid article + article {
  border-left: 1px solid var(--line);
}

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

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.structure-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.meal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 99px;
}

.breakfast {
  background: var(--gold);
}

.lunch {
  background: var(--leaf);
}

.dinner {
  background: var(--sea);
}

.snack {
  background: var(--berry);
}

.week-stack {
  display: grid;
  gap: 18px;
}

.week-table {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(54, 60, 52, 0.08);
}

.week-title {
  display: grid;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--soft-line);
  background: linear-gradient(135deg, #f6f1e4 0%, #fbf8ef 58%, #eef7f6 100%);
  color: var(--muted);
}

.week-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.week-title strong {
  color: var(--ink);
  font-size: 18px;
}

.meal-grid-scroll {
  overflow-x: hidden;
}

.meal-grid {
  display: grid;
  grid-template-columns: 76px repeat(7, minmax(132px, 1fr));
}

.meal-grid > div {
  min-height: 112px;
  padding: 12px;
  border-right: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
}

.meal-grid > div:nth-child(8n) {
  border-right: 0;
}

.meal-grid > div:nth-last-child(-n + 8) {
  border-bottom: 0;
}

.day-label,
.meal-label {
  background: #faf8f0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.day-label {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 72px;
}

.date-line {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.holiday-line {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e4f3fb;
  color: #2f7fac;
  font-weight: 700;
  font-size: 12px;
}

.day-label.has-holiday {
  background: #f3fbff;
}

.empty-cell {
  background: repeating-linear-gradient(135deg, #fbfaf6, #fbfaf6 8px, #f5f2e8 8px, #f5f2e8 16px);
}

.meal-label {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2f3b35;
  font-size: 15px;
  writing-mode: vertical-rl;
  letter-spacing: 0;
}

.recipe-link {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0f2119;
  text-align: left;
  cursor: pointer;
}

.recipe-link em {
  font-size: 15px;
  line-height: 1.3;
  font-style: italic;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.recipe-cell span {
  display: block;
  color: #33413b;
  font-size: 12px;
}

.recipe-lines {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipe-lines li {
  position: relative;
  padding-left: 11px;
  color: #46554e;
  font-size: 12px;
  line-height: 1.45;
}

.recipe-lines li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 4px;
  height: 4px;
  border-radius: 99px;
  background: rgba(23, 35, 30, 0.32);
}

.recipe-cell[data-type="breakfast"] {
  background: var(--cream);
}

.recipe-cell[data-type="lunch"] {
  background: var(--mint);
}

.recipe-cell[data-type="dinner"] {
  background: var(--sky);
}

.recipe-cell[data-type="snack"] {
  background: var(--rose);
}

.weekly-shopping {
  display: grid;
  grid-template-columns: 84px repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  padding: 0;
  border-top: 0;
  background: transparent;
}

.weekly-shopping strong {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cce4ef;
  border-radius: 8px;
  background: linear-gradient(180deg, #e7f7fc, #d9edf6);
  color: #336f95;
  font-size: 13px;
  font-weight: 800;
}

.weekly-shopping span {
  display: grid;
  gap: 3px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #d8e7ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: #33413b;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.weekly-shopping b {
  display: block;
  color: #255c7f;
  font-size: 12px;
}

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

.shopping-category {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 12px;
}

.shopping-category h3 {
  margin: 0 0 9px;
  font-size: 16px;
}

.shopping-category label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 0;
  color: #33413b;
  font-size: 14px;
}

.shopping-category input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--leaf);
}

.recipe-dialog {
  width: min(620px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(20, 30, 24, 0.22);
}

.recipe-dialog::backdrop {
  background: rgba(21, 28, 24, 0.42);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.recipe-dialog ol {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 24px;
}

.recipe-source {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.recipe-source a {
  color: #2f7fac;
}

@media (max-width: 1100px) {
  .setup-panel {
    grid-template-columns: 1fr;
  }

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

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

  .guidance-grid article + article {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .meal-grid-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .meal-grid {
    min-width: 980px;
  }

  .weekly-shopping {
    grid-template-columns: 1fr 1fr;
  }

  .week-table {
    overflow-x: hidden;
  }
}

@media (max-width: 620px) {
  .app-shell,
  .hero-content {
    width: min(100% - 20px, 1280px);
  }

  .toolbar,
  .setup-actions,
  .section-head,
  .poster-head,
  .week-title-row,
  .actions,
  .cookbook-actions,
  .member-actions {
    display: grid;
    justify-content: stretch;
  }

  .weekly-shopping {
    grid-template-columns: 1fr;
  }

  .people-grid,
  .cookbook-grid,
  .shopping-grid,
  dl {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  .app-hero,
  .toolbar,
  .people-panel,
  .guidance-grid,
  .shopping-panel {
    display: none;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

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

  .poster-head {
    display: none;
  }

  .week-stack {
    display: block;
    gap: 0;
  }

  .week-table {
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
    box-shadow: none;
    margin: 0;
  }

  .week-table:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .week-title {
    gap: 4px;
    padding: 8px 10px 7px;
  }

  .week-title strong {
    font-size: 15px;
  }

  .meal-grid {
    min-width: 0 !important;
    grid-template-columns: 50px repeat(7, minmax(0, 1fr));
  }

  .meal-grid > div {
    min-height: 82px;
    padding: 4px;
  }

  .meal-grid > div:nth-child(-n + 8) {
    min-height: 44px;
  }

  .recipe-link em {
    font-size: 9px;
  }

  .recipe-cell span,
  .recipe-lines li,
  .day-label,
  .meal-label,
  .week-title {
    font-size: 8px;
    line-height: 1.28;
  }

  .recipe-lines {
    margin-top: 4px;
  }

  .weekly-shopping {
    grid-template-columns: 58px repeat(4, minmax(0, 1fr));
    gap: 3px;
  }

  .weekly-shopping strong,
  .weekly-shopping span {
    min-height: 0;
    padding: 4px 5px;
    font-size: 7px;
    line-height: 1.25;
  }

  .weekly-shopping b {
    font-size: 8px;
  }
}
