:root {
  color-scheme: light;
  --bg: #faf6f1;
  --surface: #ffffff;
  --ink: #292420;
  --ink-soft: #4c463f;
  --muted: #7d7468;
  --line: #e8ded1;
  --accent: #c2431d;
  --accent-dark: #9c3413;
  --accent-soft: #fdeee6;
  --green: #1d7a41;
  --green-bg: #e5f3ea;
  --amber: #96660a;
  --amber-bg: #fbf0d7;
  --gray: #5d6066;
  --gray-bg: #edecea;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- sticky filter header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 246, 241, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
}
.search-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  max-width: 760px; margin: 0 auto; align-items: center;
}
.search-wrap { position: relative; flex: 1 1 220px; min-width: 0; }
.sort-wrap { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.sort-label { font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
#sortSelect {
  height: 52px;
  font: inherit; font-size: 15px; font-weight: 500;
  color: var(--ink);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d7468' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 0 36px 0 16px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#sortSelect:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; color: var(--muted); pointer-events: none;
}
#searchInput {
  width: 100%;
  height: 52px;
  padding: 0 46px 0 44px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#searchInput::placeholder { color: var(--muted); }
#clearSearch {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: none; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 20px; line-height: 1;
  cursor: pointer; display: none;
}
#clearSearch.show { display: block; }

.filters { max-width: 760px; margin: 0 auto; padding: 12px 16px 0; }
.chip-row {
  display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 2px;
}
.chip-row + .chip-row { margin-top: 8px; }
.chip {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 16px;
  font: inherit; font-size: 15px; font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700;
}
.chip.tag-chip[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink);
}
.row-label {
  flex: 0 0 auto; align-self: center;
  font-size: 13px; color: var(--muted); font-weight: 700; padding-right: 2px;
}

.count-bar {
  margin-top: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#resultCount { font-size: 15px; font-weight: 700; color: var(--ink); }
#resultCount .total { color: var(--muted); font-weight: 500; }
#resetFilters {
  border: none; background: none; font: inherit; font-size: 14px;
  color: var(--accent); font-weight: 700; cursor: pointer; padding: 6px 2px;
  display: none;
}
#resetFilters.show { display: block; }

/* ---------- cards ---------- */
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(80, 55, 30, 0.05);
}
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-title { font-size: 20px; font-weight: 900; line-height: 1.35; margin: 0; flex: 1; }
.badge {
  flex: 0 0 auto; margin-top: 3px;
  font-size: 12.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-full { color: var(--green); background: var(--green-bg); }
.badge-partial { color: var(--amber); background: var(--amber-bg); }
.badge-unavailable { color: var(--gray); background: var(--gray-bg); }
.card-meta { margin-top: 4px; font-size: 14px; color: var(--muted); }
.card-meta .cat { color: var(--ink-soft); font-weight: 500; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 13px; font-weight: 500; color: var(--accent-dark);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 10px;
}
.note {
  margin-top: 12px; font-size: 14px; color: var(--ink-soft);
  background: #faf3e8; border-radius: 10px; padding: 9px 12px;
}
.summary { margin-top: 12px; font-size: 15.5px; }
.summary p { margin: 0 0 6px; }
.summary .lbl { font-weight: 700; color: var(--ink-soft); }

.toggle-btn {
  margin-top: 14px; width: 100%;
  min-height: 46px;
  font: inherit; font-size: 15.5px; font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: none; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.toggle-btn .chev { transition: transform 0.18s ease; font-size: 13px; }
.toggle-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.card-body { margin-top: 14px; }
.card-body[hidden] { display: none; }
.section-title {
  font-size: 15px; font-weight: 900; color: var(--ink);
  margin: 14px 0 8px; display: flex; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
ul.ing { list-style: none; margin: 0; padding: 0; }
ul.ing li {
  position: relative; padding: 3px 0 3px 18px; font-size: 15.5px;
}
ul.ing li::before {
  content: ""; position: absolute; left: 3px; top: 13px;
  width: 6px; height: 6px; border-radius: 999px; background: var(--accent);
}
ol.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
ol.steps li {
  counter-increment: step; position: relative;
  padding: 4px 0 4px 36px; font-size: 15.5px;
}
ol.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 4px;
  width: 25px; height: 25px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.post-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px; min-height: 44px; padding: 8px 4px;
  font-size: 15.5px; font-weight: 700; color: var(--accent);
  text-decoration: none;
}
.post-link:active { color: var(--accent-dark); }
.card-foot {
  border-top: 1px solid var(--line); margin-top: 6px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.card-foot .post-link { margin-top: 0; }
.del-btn {
  margin-left: auto;
  font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--muted); background: none; border: none;
  cursor: pointer; padding: 10px 4px; min-height: 44px;
}
.del-btn:active { color: var(--accent-dark); }
.del-confirm {
  flex: 1 1 100%;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0 2px;
}
.del-msg { flex: 1 1 150px; font-size: 14.5px; font-weight: 700; color: var(--ink-soft); }
.del-yes {
  font: inherit; font-size: 14px; font-weight: 700;
  color: #fff; background: var(--accent); border: none;
  border-radius: 999px; padding: 9px 18px; cursor: pointer; min-height: 42px;
}
.del-yes:active { background: var(--accent-dark); }
.del-no {
  font: inherit; font-size: 14px; font-weight: 700;
  color: var(--ink-soft); background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px; padding: 9px 18px; cursor: pointer; min-height: 42px;
}

.empty {
  text-align: center; padding: 56px 24px;
  color: var(--muted);
}
.empty .big { font-size: 19px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.empty button {
  margin-top: 16px; font: inherit; font-size: 15px; font-weight: 700;
  color: #fff; background: var(--accent); border: none;
  border-radius: 999px; padding: 12px 26px; cursor: pointer; min-height: 46px;
}
@media (prefers-reduced-motion: reduce) {
  .toggle-btn .chev { transition: none; }
  .chip:active { transform: none; }
}
/* ---------- 寶藏食譜 additions ---------- */
.brand {
  max-width: 760px; margin: 0 auto;
  padding: 14px 16px 0;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 10px;
}
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: 0.02em; }
.status-msg {
  max-width: 760px; margin: 0 auto; padding: 56px 24px;
  text-align: center; color: var(--muted);
}
.status-msg .big { font-size: 19px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.status-msg button {
  margin-top: 16px; font: inherit; font-size: 15px; font-weight: 700;
  color: #fff; background: var(--accent); border: none;
  border-radius: 999px; padding: 12px 26px; cursor: pointer; min-height: 46px;
}
