:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2a2520;
  --muted: #7a6f64;
  --line: #e8e0d4;
  --accent: #b5532b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6dc;
  --danger: #b3261e;
  --radius: 14px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --surface: #24201c;
    --ink: #f1ebe3;
    --muted: #a99d90;
    --line: #3a332c;
    --accent: #e2835a;
    --accent-ink: #1a1714;
    --accent-soft: #3b2a20;
    --danger: #f2877f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }
h1, h2 { font-family: var(--serif); font-weight: 650; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0 0 .4rem; }
h2 { font-size: 1.3rem; margin: 0 0 .8rem; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 64px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; font-weight: 400; }
[hidden] { display: none !important; }

/* header */
.top { max-width: 1040px; margin: 0 auto; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--serif); font-weight: 650; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.muted-link { color: var(--muted); text-decoration: none; font-size: .95rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 600 .95rem var(--sans); padding: 10px 18px; border-radius: 999px; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn.small { padding: 6px 14px; font-size: .88rem; min-height: 36px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); margin-left: auto; }
.btn:disabled { opacity: .55; cursor: default; }

/* list */
.list-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin: 12px 0 20px; }
.list-head h1 { margin: 0; }
.count { font-family: var(--sans); font-size: 1rem; font-weight: 500; color: var(--muted); vertical-align: middle; }
#q { flex: 1 1 260px; max-width: 380px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgb(0 0 0 / .08); }
.card img, .card .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.card .ph { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 650 3rem var(--serif); }
.card-body { padding: 14px 16px 16px; }
.card-body h2 { font-size: 1.15rem; margin: 0 0 4px; }
.card-body p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .8rem; color: var(--muted); align-items: center; }
.tag { background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.empty { text-align: center; padding: 64px 0; }

/* recipe */
.recipe { max-width: 860px; margin: 0 auto; }
.hero { width: 100%; max-height: 460px; object-fit: cover; border-radius: var(--radius); display: block; margin: 8px 0 20px; }
.summary { font-size: 1.1rem; color: var(--muted); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 22px 0; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.scaler { display: flex; align-items: center; gap: 8px; }
.scaler button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 1.05rem; cursor: pointer; line-height: 1; }
.scaler output { min-width: 1.5em; text-align: center; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 36px; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; gap: 20px; } }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { border-bottom: 1px solid var(--line); }
.ingredients label { display: flex; gap: 10px; padding: 9px 0; cursor: pointer; }
.ingredients input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 3px; flex: none; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.ingredients .sub { font-weight: 600; padding: 14px 0 4px; border: 0; }
.steps { padding-left: 0; margin: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 18px 44px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; display: grid; place-items: center; font-size: .9rem; }
.notes { margin-top: 28px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.notes p { margin: 0 0 10px; }
.source { color: var(--muted); font-size: .9rem; margin-top: 24px; }

/* forms */
input, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=file] { padding: 8px; }
input[type=checkbox] { width: auto; }
.editor, .login { max-width: 680px; margin: 0 auto; display: grid; gap: 16px; }
.editor label, .photo-field { display: grid; gap: 6px; font-weight: 500; }
.label { font-weight: 500; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.photo-row { display: flex; gap: 14px; align-items: start; flex-wrap: wrap; }
.photo-row > div { flex: 1 1 200px; display: grid; gap: 8px; justify-items: start; }
#photo-preview { width: 140px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.error { color: var(--danger); margin: 0; }
.login { max-width: 360px; padding-top: 40px; text-align: center; }

@media print {
  .top, .no-print, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
  .hero { max-height: 240px; }
  .facts, .notes { border-color: #ccc; }
  .ingredients input { display: none; }
}
