:root {
  --ink: #29251f;
  --muted: #776f63;
  --paper: #fffdf8;
  --cream: #f5efe5;
  --orange: #dd6d39;
  --line: #e5ded1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: ui-rounded, "Noto Sans TC", system-ui, sans-serif;
}

.topbar {
  min-height: 72px;
  padding: 16px max(24px, calc((100vw - 1100px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand { color: inherit; font-size: 20px; font-weight: 800; text-decoration: none; }
.add-button, button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.back-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; }
.page { width: min(1100px, calc(100% - 48px)); margin: 0 auto; padding: 50px 0 80px; }
.intro { margin-bottom: 34px; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(31px, 5vw, 52px); line-height: 1.18; letter-spacing: -.04em; }
.status { padding: 32px; text-align: center; color: var(--muted); background: var(--cream); border-radius: 16px; }
.load-more { min-height: 56px; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }

.meal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; align-items: start; }
.meal-card-link { display: block; color: inherit; text-decoration: none; }
.meal-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 5px 18px #60421a0b; transition: transform .15s ease, box-shadow .15s ease; }
.meal-card-link:hover .meal-card { transform: translateY(-3px); box-shadow: 0 10px 24px #60421a1a; }
.meal-card-link:focus-visible { outline: 3px solid #f3b392; outline-offset: 3px; border-radius: 16px; }
.meal-images { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; background: var(--cream); }
.meal-images:has(img:only-child) { grid-template-columns: 1fr; }
.meal-images img { width: 100%; display: block; aspect-ratio: 1 / 1; object-fit: cover; }
.meal-images:has(img:only-child) img { max-height: 390px; aspect-ratio: auto; }
.meal-content { padding: 17px; }
.meal-meta { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; color: var(--muted); font-size: 13px; }
.meal-type { background: #f9dfd2; color: #a4491e; padding: 4px 8px; border-radius: 999px; font-weight: 700; }
h2 { margin: 11px 0 8px; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.details { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; min-height: 1.2em; }

.form-page { max-width: 660px; }
.form-page h1 { margin-bottom: 28px; }
.meal-form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; font-size: 14px; font-weight: 700; }
label strong { color: var(--orange); font-size: 12px; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  font: inherit;
  font-size: 16px;
}
textarea { min-height: 132px; resize: vertical; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.meal-type-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.meal-type-picker legend { margin-bottom: 8px; padding: 0; font-size: 14px; font-weight: 700; }
.meal-type-picker strong { color: var(--orange); font-size: 12px; }
.meal-type-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.four-options { grid-template-columns: repeat(4, 1fr); }
.three-options { grid-template-columns: repeat(3, 1fr); }
.meal-type-option { display: block; cursor: pointer; }
.meal-type-option input { position: absolute; width: 1px; min-height: 1px; opacity: 0; pointer-events: none; }
.meal-type-option span { min-height: 48px; display: grid; place-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--muted); font-size: 15px; font-weight: 700; }
.meal-type-option input:checked + span { border-color: var(--orange); background: var(--orange); color: #fff; }
.meal-type-option input:focus-visible + span { outline: 3px solid #f3b392; outline-offset: 2px; }
.upload-box { min-height: 210px; place-items: center; text-align: center; color: var(--muted); border: 2px dashed #d9cdbc; border-radius: 16px; cursor: pointer; overflow: hidden; }
.photo-previews { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; background: var(--cream); }
.photo-previews img { width: 100%; height: 100%; min-height: 100px; object-fit: cover; }
.menu-upload-section { display: grid; gap: 14px; margin-top: 6px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--cream); }
.section-label { margin: 0; font-weight: 800; }
.section-label span { color: var(--orange); font-size: 12px; }
.section-help { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.menu-upload-box { min-height: 170px; background: #fff; }
small { font-weight: 400; }
.form-status { min-height: 1.2em; margin: 0; color: #bd392a; }
.meal-form button { min-height: 52px; font-size: 16px; }
button:disabled { opacity: .65; cursor: wait; }

@media (max-width: 600px) {
  .topbar { position: sticky; z-index: 5; top: 0; min-height: 60px; padding: 8px 16px; background: #fffdf8ed; backdrop-filter: blur(12px); }
  .brand { font-size: 18px; }
  .page { width: min(100% - 32px, 1100px); padding: 32px 0 calc(100px + env(safe-area-inset-bottom)); }
  .intro { margin-bottom: 24px; }
  h1 { font-size: 32px; }
  .meal-list { grid-template-columns: 1fr; gap: 16px; }
  .meal-card { border-radius: 14px; }
  .meal-images:has(img:only-child) img { max-height: none; aspect-ratio: 4 / 3; }
  .meal-content { padding: 15px; }
  .add-button { position: fixed; z-index: 10; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); min-width: 56px; min-height: 56px; display: grid; place-items: center; padding: 12px 18px; box-shadow: 0 10px 26px #8f3b1980; }
  .back-link { font-size: 14px; }
  .form-row { grid-template-columns: 1fr; gap: 18px; }
  .meal-type-options { grid-template-columns: repeat(3, 1fr); }
  .four-options, .rating-options { grid-template-columns: repeat(2, 1fr); }
  .three-options { grid-template-columns: repeat(3, 1fr); }
  .upload-box { min-height: 250px; }
  .meal-form button { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 8px 22px #8f3b1940; }
}
