:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --ink: #23201c;
  --muted: #6d675f;
  --line: #e4ded5;
  --accent: #8a4b2a;
  --danger: #a3302a;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #232019;
    --ink: #f0ebe4;
    --muted: #a39c92;
    --line: #38332c;
    --accent: #d99460;
    --danger: #e0756c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

a { color: var(--accent); }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.prewrap { white-space: pre-wrap; }
.empty { padding: 40px 0; }

/* header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 12px; }
.topbar form { margin: 0; }

/* controls */
button, .button {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}
button.danger { background: var(--danger); }
button.linkish, .linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; }
label { display: block; font-weight: 550; margin-bottom: 4px; }

.stack { display: flex; flex-direction: column; gap: 6px; }
.stack > label:not(:first-of-type) { margin-top: 14px; }
.stack > button { margin-top: 18px; align-self: flex-start; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1 1 160px; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.actions form { margin: 0; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 24px; }
.filters input[type="search"] { flex: 3 1 240px; width: auto; }
.filters select { flex: 1 1 150px; width: auto; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.flash-ok { background: #e6f2e6; color: #1f5127; }
.flash-error { background: #f8e4e2; color: #7d2420; }

.centered { max-width: 340px; margin: 12vh auto; }

/* recipe cards */
.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card a { text-decoration: none; color: inherit; display: block; height: 100%; }
.card h2 { margin: 0 0 6px; font-size: 1.05rem; }
.card p { margin: 0 0 6px; font-size: 0.9rem; }
.card-body { padding: 14px; }
.thumb { width: 100%; height: 150px; object-fit: cover; display: block; }
.thumb-empty { background: linear-gradient(135deg, var(--line), var(--bg)); }

.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.pill {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.78rem;
}

/* recipe detail */
.recipe .hero {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 18px 0;
}
.recipe a { overflow-wrap: anywhere; }
