:root {
  color-scheme: light;
  --paper: #faf6ee;
  --card: #fffdf8;
  --ink: #30271f;
  --muted: #6c5c4e;
  --line: #e9ded0;
  --accent: #88392e;
  --brick: #703024;
  --cream: #fff0d4;
  --serif: "Noto Serif CJK SC", "Songti SC", "STSong", SimSun, serif;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #ad5335;
  outline-offset: 3px;
}
img { display: block; max-width: 100%; }

.frame { width: min(1080px, 100% - 64px); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--line); background: #fdf9f2; }
.topbar-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
  background: none;
  border: 0;
  padding: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
}
.brand img { border-radius: 13px; }
.tabs { display: flex; padding: 4px; gap: 3px; background: #f2eae0; border-radius: 100px; }
.tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 41px;
  border: 0;
  border-radius: 100px;
  padding: 0 16px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}
.tabs button[aria-current="page"] { color: var(--accent); background: var(--card); box-shadow: 0 1px 3px #49301a14; }
.tab-count { background: #f4e5db; color: var(--accent); border-radius: 100px; min-width: 20px; padding: 0 4px; text-align: center; font-size: 11px; line-height: 20px; }
.tab-icon { width: 21px; height: 21px; background-position: center; background-size: contain; background-repeat: no-repeat; }
.tab-icon-library { background-image: url("./assets/library.png"); }
.tab-icon-today { background-image: url("./assets/today.png"); }
.tabs button[aria-current="page"] .tab-icon-library { background-image: url("./assets/library-active.png"); }
.tabs button[aria-current="page"] .tab-icon-today { background-image: url("./assets/today-active.png"); }
.backup-button {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.backup-button span { padding-right: 2px; font-size: 19px; vertical-align: -1px; }

main.frame { padding-block: 30px 64px; }
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 310px;
  border-radius: 25px;
  background: var(--brick);
  color: var(--cream);
}
.hero-copy { position: relative; z-index: 2; padding: 36px 0 38px 46px; }
.hero-date { display: flex; align-items: center; gap: 11px; color: #ffdeb0; font-size: 14px; letter-spacing: .075em; }
.hero-date::before { content: ""; width: 24px; height: 1px; background: #edb690; }
.hero h1 { margin: 14px 0 10px; font: 700 clamp(38px, 5.1vw, 64px)/1.15 var(--serif); letter-spacing: -.04em; }
#hero-summary { color: #fae0d0; font-size: 16px; margin-bottom: 24px; }
.hero-art { position: absolute; right: 0; top: 0; width: 57%; height: 100%; object-fit: cover; object-position: 62% 55%; }
.hero::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0 0 0 39%;
  background: linear-gradient(90deg, var(--brick) 5%, #7030246e 24%, transparent 47%);
  pointer-events: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.2;
  white-space: nowrap;
}
.button-primary { background: var(--accent); color: #fff9f0; }
.button-cream { background: #fff0d3; color: #742d22; }
.button-outline { border-color: #dfcfc1; background: var(--card); color: var(--accent); }
.button-primary:hover { background: #713027; }
.button-cream:hover, .button-outline:hover { background: #f7e8d8; }
.button span[aria-hidden] { font-size: 19px; line-height: 1; }
.muted { color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 35px; }
.section-head h2, .today h1 { font: 700 34px/1.22 var(--serif); letter-spacing: -.035em; }
.section-head p { margin-top: 5px; font-size: 13px; }
.filter-row { display: flex; gap: 14px; justify-content: space-between; align-items: center; margin: 20px 0 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filter {
  min-height: 42px;
  padding: 0 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.filter[aria-pressed="true"] { color: #fffaf1; border-color: var(--accent); background: var(--accent); font-weight: 680; }
.random-button { flex-shrink: 0; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dish {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 2px 5px #5e392008;
}
.plate { position: relative; overflow: hidden; background: #eee4d0; color: #987449; }
.plate[data-tone="sage"] { background: #e6e8da; color: #708065; }
.plate[data-tone="rose"] { background: #f2dfd7; color: #a66c62; }
.plate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(37%, 90px);
  aspect-ratio: 1;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 52%, currentColor 53%, transparent 55%);
  opacity: .52;
}
.plate img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dish-cover { display: block; width: 100%; aspect-ratio: 1.45; padding: 0; border: 0; border-bottom: 1px solid var(--line); }
.dish-cover:focus-visible { z-index: 1; outline-offset: -3px; }
.dish-body { padding: 15px; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.category-badge { display: inline-block; padding: 4px 9px; border-radius: 100px; font-size: 12px; line-height: 1.35; color: #6a4f20; background: #f6ebd5; }
.category-badge[data-tone="sage"] { color: #4d6144; background: #e9ecdf; }
.category-badge[data-tone="rose"] { color: #873c36; background: #f7e8e2; }
.dish-title { border: 0; background: none; text-align: left; padding: 0; font-size: inherit; font-weight: inherit; overflow-wrap: anywhere; }
.dish-title:hover { color: var(--accent); }
.dish-body h3 { font-size: 23px; font-weight: 720; line-height: 1.24; }
.ingredients { color: var(--muted); font-size: 13px; line-height: 1.55; min-height: 2lh; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.button-join { align-self: stretch; margin-top: auto; border-radius: 11px; background: #f6e8dd; color: var(--accent); }
.button-join[aria-pressed="true"] { background: #e8eddf; color: #3e5736; }
.button-join:hover { box-shadow: inset 0 0 0 1px #754d312d; }

.today { max-width: 800px; margin-inline: auto; }
.today-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin: 12px 0 26px; }
.date-tag { margin-bottom: 9px; color: var(--accent); font-size: 14px; letter-spacing: .06em; }
#today-summary { margin-top: 8px; font-size: 14px; }
.today-list { display: grid; gap: 13px; }
.meal {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 14px;
}
.meal-cover { width: 100%; aspect-ratio: 1; border-radius: 12px; }
.meal h2 { margin-top: 6px; font-size: 22px; }
.meal-ingredients { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.meal-ingredients li { padding: 4px 8px; border-radius: 7px; background: #f7f1e7; overflow-wrap: anywhere; }
.remove-button { min-height: 42px; padding-inline: 13px; }
.empty { padding: 35px 20px; border: 1px dashed #ddcdbc; border-radius: 20px; background: #fffbf4; text-align: center; }
.empty h3 { margin-bottom: 10px; font-size: 21px; }
.empty p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

dialog {
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  width: min(530px, 100% - 28px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  box-shadow: 0 20px 54px #49271835;
}
dialog::backdrop { background: #3221177d; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-head h2 { font: 700 26px/1.2 var(--serif); overflow-wrap: anywhere; }
.close-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #f3eade; color: var(--muted); font-size: 26px; flex-shrink: 0; }
.editor-fields { display: grid; grid-template-columns: 1.35fr 1fr; gap: 13px; margin-bottom: 14px; }
.editor-fields label { min-width: 0; }
label { display: block; font-size: 15px; font-weight: 650; }
input[type="text"], textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--ink);
  border: 1px solid #e2d5c5;
  border-radius: 10px;
  background: #fcf7ee;
  font-size: 16px;
  font-weight: 400;
}
textarea { resize: vertical; min-height: 95px; }
.field-note { margin-left: 5px; font-size: 12px; font-weight: 400; }
.image-field { display: flex; align-items: center; gap: 14px; margin-top: 15px; }
.field-title { margin-bottom: 6px; font-size: 15px; font-weight: 650; }
.editor-photo { width: 80px; height: 72px; border-radius: 10px; flex: 0 0 auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.form-error { margin-top: 12px; color: #a32925; font-size: 13px; }
.suggestion-art { height: clamp(150px, 32dvh, 270px); border-radius: 12px; }
.suggestion-ingredients, #backup p { color: var(--muted); line-height: 1.65; font-size: 14px; overflow-wrap: anywhere; }
.suggestion-ingredients { margin-top: 13px; }
.toast {
  position: fixed;
  inset: auto 16px 26px;
  z-index: 9;
  margin-inline: auto;
  width: fit-content;
  max-width: min(400px, 100% - 32px);
  padding: 11px 18px;
  border-radius: 12px;
  color: #fff9ef;
  background: #423026;
  box-shadow: 0 6px 20px #36241730;
  text-align: center;
  font-size: 14px;
}

@media (max-width: 760px) {
  .frame { width: calc(100% - 36px); }
  .topbar-inner { min-height: 65px; gap: 10px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand img { width: 34px; height: 34px; border-radius: 11px; }
  .backup-button { min-height: 40px; padding-inline: 11px; font-size: 12px; }
  .tabs {
    position: fixed;
    z-index: 5;
    inset: auto 0 0;
    padding: 6px 13px calc(6px + env(safe-area-inset-bottom));
    background: #fffcf7;
    border-top: 1px solid var(--line);
    border-radius: 0;
    justify-content: center;
    gap: 10px;
  }
  .tabs button { flex: 1; max-width: 236px; min-height: 47px; padding-inline: 9px; }
  .tabs button[aria-current="page"] { background: #f6e9e0; box-shadow: none; }
  main.frame { padding-block: 17px calc(83px + env(safe-area-inset-bottom)); }
  .hero { min-height: 231px; border-radius: 19px; }
  .hero-copy { padding: 22px 0 24px 19px; }
  .hero h1 { margin-top: 12px; font-size: clamp(31px, 9vw, 57px); }
  .hero-date, #hero-summary { font-size: 13px; }
  #hero-summary { margin-bottom: 17px; }
  .hero-art { width: 60%; object-position: 63% 55%; }
  .hero::after { inset-inline-start: 35%; background: linear-gradient(90deg, var(--brick) 2%, #70302487 32%, transparent 72%); }
  .section-head { margin-top: 27px; }
  .section-head h2, .today h1 { font-size: 29px; }
  .filter-row { align-items: flex-start; margin: 15px 0 13px; gap: 7px; flex-direction: column; }
  .filters { gap: 6px; }
  .filter { min-height: 40px; padding-inline: 12px; font-size: 13px; }
  .random-button { align-self: flex-end; min-height: 42px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .dish { border-radius: 14px; }
  .dish-cover { aspect-ratio: 1.22; }
  .dish-body { padding: 10px; gap: 6px; }
  .dish-body h3 { font-size: 18px; }
  .ingredients { font-size: 12px; }
  .button-join { padding-inline: 5px; font-size: 13px; }
  .meal { grid-template-columns: 68px minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
  .meal h2 { font-size: 17px; }
  .meal-ingredients { font-size: 12px; }
  .remove-button { padding-inline: 9px; font-size: 12px; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .frame { width: calc(100% - 24px); }
  .editor-fields { grid-template-columns: minmax(0, 1fr); }
  .hero-copy { padding-left: 15px; }
  .hero::after { inset-inline-start: 32%; }
}
