:root {
  --bg: #f7f1e8;
  --surface: #fffaf3;
  --surface-2: #efe6d8;
  --text: #2b231c;
  --muted: #7a6c5d;
  --line: #e2d6c4;
  --accent: #b5532f;
  --accent-ink: #ffffff;
  --accent-soft: #f3dccf;
  --star: #e0a526;
  --ok: #3f7d4e;
  --warn: #a86a12;
  --warn-soft: #fbedd2;
  --danger: #b03a2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1814;
    --surface: #26201b;
    --surface-2: #322a23;
    --text: #f1e8dc;
    --muted: #a8998a;
    --line: #3d342b;
    --accent: #e07a52;
    --accent-ink: #1c1814;
    --accent-soft: #4a2c1f;
    --warn-soft: #3d2e14;
    --warn: #e7b155;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
#app { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px 24px; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 21px; margin: 28px 0 12px; }
h3 { font-size: 17px; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* ---------- tabs ---------- */
#tabs {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); padding: 4px 0; min-height: 44px; }
#tabs a .ti { font-size: 22px; line-height: 1.1; }
#tabs a.on { color: var(--accent); font-weight: 600; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 16px;
  border: 0; border-radius: 12px; cursor: pointer;
  padding: 12px 16px; min-height: 46px;
  background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:disabled { opacity: .55; }
.btn-quiet { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); padding: 8px 10px; min-height: 40px; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-block { width: 100%; }
input, textarea, select {
  font: inherit; color: var(--text);
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field + .field { margin-top: 16px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- header ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.top .date { font-size: 14px; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.pad { padding: 14px 16px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.rcard { display: block; color: inherit; }
.rcard .ph, .scard .ph { aspect-ratio: 4 / 5; background: var(--surface-2); object-fit: cover; width: 100%; }
.rcard .ph.none, .scard .ph.none { display: grid; place-items: center; font-size: 40px; }
.rcard .body { padding: 10px 12px 12px; }
.rcard .t { font-weight: 650; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

.scroller { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scard { flex: 0 0 72%; max-width: 280px; scroll-snap-align: start; color: inherit; display: block; }
.scard .ph { aspect-ratio: 4 / 3; }
.scard .body { padding: 12px 14px 14px; }
.scard .t { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.25; }
.why { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 2px 9px; margin-top: 8px; }

.stars-mini { color: var(--star); letter-spacing: 1px; }
.chip { display: inline-flex; align-items: center; font-size: 13px; padding: 5px 11px; border-radius: 99px; background: var(--surface-2); color: var(--text); border: 1px solid transparent; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
button.chip { min-height: 34px; font-weight: 500; }

/* ---------- jobs ---------- */
.job { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.job + .job { border-top: 1px solid var(--line); }
.job .txt { flex: 1; min-width: 0; }
.job .u { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.banner { border-radius: 12px; padding: 12px 14px; font-size: 15px; background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }

/* ---------- recipe page ---------- */
.hero { margin: -12px -16px 0; position: relative; }
.hero img { width: 100%; max-height: 62vh; object-fit: cover; }
.hero .back { position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 12px; background: rgba(0,0,0,.45); color: #fff; border-radius: 99px; min-height: 40px; padding: 8px 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.back-plain { margin-left: -10px; }
.rtitle { font-size: 30px; margin: 18px 0 6px; }
.byline { font-size: 14px; color: var(--muted); }
.facts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px; font-size: 14px; }
.fact b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

.rate { display: grid; gap: 8px; margin: 16px 0; }
.rate .who { width: 64px; font-size: 14px; font-weight: 600; color: var(--muted); flex: none; overflow: hidden; text-overflow: ellipsis; }
.stars { display: flex; }
.stars button { background: none; color: var(--line); font-size: 30px; padding: 0 3px; min-height: 44px; min-width: 40px; line-height: 1; }
.stars button.on { color: var(--star); }
.stars.readonly button { cursor: default; }

.ing { list-style: none; padding: 0; margin: 0; }
.ing li { padding: 11px 4px 11px 36px; border-bottom: 1px solid var(--line); position: relative; cursor: pointer; }
.ing li::before { content: ""; position: absolute; left: 4px; top: 13px; width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 6px; }
.ing li.done { color: var(--muted); text-decoration: line-through; }
.ing li.done::before { background: var(--accent); border-color: var(--accent); }
.ing li.group { padding-left: 4px; cursor: default; border-bottom: 0; font-family: var(--serif); font-weight: 600; font-size: 17px; padding-top: 18px; }
.ing li.group::before { display: none; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 12px 12px 12px 48px; border-radius: 12px; cursor: pointer; }
.steps li::before { content: counter(s); position: absolute; left: 10px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.steps li.cur { background: var(--accent-soft); }
.steps li.cur::before { background: var(--accent); color: var(--accent-ink); }
.steps li.group { counter-increment: none; padding-left: 4px; font-family: var(--serif); font-weight: 600; cursor: default; }
.steps li.group::before { display: none; }
.cook-mode .steps li { font-size: 20px; }
.cook-mode .ing li { font-size: 19px; }
.photos { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.photos img { height: 160px; width: auto; border-radius: 12px; flex: none; }
.notes { white-space: pre-wrap; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 44px; }
.center-screen { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.logo { font-size: 56px; text-align: center; }
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-size: 15px; max-width: calc(100vw - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-pick button.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
ol.howto { padding-left: 22px; }
ol.howto li + li { margin-top: 6px; }
