/* ---------- Site ---------- */
:root {
  --page: #f6f3ee;
  --surface: #ffffff;
  --ink: #222019;
  --muted: #6d675c;
  --line: #e2dcd1;
  --accent: #9c4a1a;
  --accent-ink: #ffffff;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #161513;
    --surface: #211f1c;
    --ink: #efebe4;
    --muted: #a39c8f;
    --line: #3a3630;
    --accent: #e0834f;
    --accent-ink: #161513;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.site-head nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-head nav a { text-decoration: none; }

h1, h2, h3 { line-height: 1.2; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; margin: 0 0 4px; }
h2 { font-size: 1.25rem; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 20px;
}

.search {
  flex: 1 1 260px;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 4px 10px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.recipe-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}

.recipe-tile:hover { border-color: var(--accent); }
.recipe-tile h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; }
.recipe-tile p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--page);
  border: 1px solid var(--line);
  color: var(--muted);
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}

.btn-small { padding: 6px 14px; font-size: 0.9rem; }
.btn-ghost { color: var(--accent); background: transparent; }
.btn-danger { color: #b3261e; background: transparent; border-color: #b3261e; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0; }

/* ---------- Recipe detail ---------- */
.detail-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); margin: 8px 0 0; }
.detail-cols { display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .detail-cols { grid-template-columns: 1fr 1.6fr; }
}

.ing-list { list-style: none; padding: 0; margin: 0; }
.ing-list li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.ing-list .amt { min-width: 7.5em; font-weight: 600; font-variant-numeric: tabular-nums; }

.steps { padding-left: 1.4em; margin: 0; }
.steps li { margin-bottom: 12px; }

.notes {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
}

/* ---------- Forms ---------- */
form.recipe-form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 0.9rem; font-weight: 600; }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .field-row { grid-template-columns: 1fr 1fr 1fr; }
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea { min-height: 80px; resize: vertical; }

fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
}

legend { padding: 0 6px; font-weight: 700; font-family: Georgia, serif; }

.ing-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 90px 1fr;
  align-items: center;
}
.ing-row .name { grid-column: 1 / -1; }
.ing-row .cat, .ing-row .unit { min-width: 0; }
.ing-row .icon-btn { justify-self: end; }
@media (min-width: 620px) {
  .ing-row { grid-template-columns: 90px 130px 130px 1fr auto; }
  .ing-row .name { grid-column: auto; }
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.step-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: start; }
.step-num { padding-top: 10px; text-align: right; color: var(--muted); font-weight: 600; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140%);
  transition: transform 0.25s ease;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  color: var(--accent-ink);
  background: var(--ink);
  border-radius: 10px;
  font-size: 0.95rem;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #b3261e; color: #fff; }

/* ---------- Card view (screen) ---------- */
.card-view {
  display: grid;
  gap: 24px;
  justify-items: center;
}

.card-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: center;
  width: 100%;
  max-width: 560px;
}
.card-controls .field { flex: 1 1 200px; }

.preview-note { text-align: center; max-width: 520px; }

/* ---------- 4x6 recipe cards ----------
   Each template only sets tokens and a few layout tweaks, so the content
   markup stays identical. The card is exactly 4in x 6in so printing at
   100% scale (or "actual size") gives a true card. */

.card {
  --bg: #fff;
  --ink: #222;
  --accent: #555;
  --rule: #ccc;
  --head-bg: transparent;
  --head-ink: var(--ink);
  --head-font: Georgia, "Times New Roman", serif;
  --body-font: Georgia, "Times New Roman", serif;
  --card-border: none;
  --radius-card: 0;
  --pad: 0.24in;
  --base: 9pt;

  position: relative;
  width: 4in;
  height: 6in;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: var(--base);
  line-height: 1.35;
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
  text-align: left;
}

.card.d-compact { --base: 7.5pt; line-height: 1.25; }

.card h2, .card h3 { margin: 0; line-height: 1.15; }

.card-head {
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.card-head h2 {
  font-family: var(--head-font);
  font-size: 1.45em;
  font-weight: 700;
  color: var(--head-ink);
  margin: 0 0 2px;
}

.card-desc { margin: 0 0 4px; font-style: italic; color: var(--accent); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.card-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.05fr 1.35fr;
  gap: 14px;
}

.card h3 {
  font-family: var(--head-font);
  font-size: 1.02em;
  margin-bottom: 4px;
  color: var(--accent);
}

.card-ing ul { list-style: none; margin: 0; padding: 0; }
.card-ing li {
  padding: 2px 0;
  border-bottom: 1px dotted var(--rule);
}
.card-ing .q { font-weight: 700; margin-right: 3px; }

.card-method ol { margin: 0; padding-left: 1.25em; }
.card-method li { margin-bottom: 3px; }

.card-foot {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--rule);
  font-size: 0.85em;
  font-style: italic;
  color: var(--accent);
  max-height: 0.9in;
  overflow: hidden;
}
.card-foot p { margin: 0; }

/* 1. Classic Cream: double frame, serif, warm ink */
.card.t-classic {
  --bg: #fbf6ea;
  --ink: #3b2a1a;
  --accent: #9c4a1a;
  --rule: #d8c7a6;
  --head-font: Georgia, "Times New Roman", serif;
  --card-border: 3px double #9c4a1a;
  --pad: 0.28in;
}
.card.t-classic .card-head { text-align: center; }
.card.t-classic .card-meta { justify-content: center; }

/* 2. Garden Sage: solid header band, soft rounded frame */
.card.t-sage {
  --bg: #eef3e8;
  --ink: #223a2a;
  --accent: #4f7a57;
  --rule: #b9cbb4;
  --head-font: "Palatino Linotype", Palatino, "Book Antiqua", serif;
  --body-font: "Palatino Linotype", Palatino, "Book Antiqua", serif;
  --card-border: 1px solid #4f7a57;
  --radius-card: 14px;
  --pad: 0;
}
.card.t-sage .card-head {
  margin: 0;
  padding: 0.22in 0.24in 8px;
  background: #4f7a57;
  border-bottom: none;
  color: #f4f8f1;
}
.card.t-sage .card-head h2 { color: #f4f8f1; }
.card.t-sage .card-desc, .card.t-sage .card-meta { color: #dcebd5; }
.card.t-sage .card-body,
.card.t-sage .card-foot { padding: 0 0.24in; }
.card.t-sage .card-body { padding-top: 10px; }
.card.t-sage .card-foot { margin-bottom: 0.2in; }
.card.t-sage h3 { color: #4f7a57; }

/* 3. Modern Slate: dark card, sans-serif, gold accent */
.card.t-slate {
  --bg: #1f2730;
  --ink: #e6ebf1;
  --accent: #f0b429;
  --rule: #3a4654;
  --head-font: Helvetica, Arial, sans-serif;
  --body-font: Helvetica, Arial, sans-serif;
  --card-border: none;
  --pad: 0.26in;
}
.card.t-slate .card-head { border-bottom: 3px solid #f0b429; }
.card.t-slate .card-head h2 { text-transform: uppercase; letter-spacing: 0.03em; font-size: 1.3em; }
.card.t-slate .card-ing li { border-color: #3a4654; }
.card.t-slate .card-desc { color: #aab6c4; }

/* 4. Kraft Recipe: typewriter feel, dashed stamp border */
.card.t-kraft {
  --bg: #d8b98a;
  --ink: #2e1f0f;
  --accent: #6b3e1d;
  --rule: #a98256;
  --head-font: "Courier New", Courier, monospace;
  --body-font: "Courier New", Courier, monospace;
  --card-border: 2px dashed #6b3e1d;
  --pad: 0.24in;
}
.card.t-kraft .card-head h2 { font-size: 1.3em; text-decoration: underline; text-underline-offset: 4px; }
.card.t-kraft .card-meta { font-weight: 700; }

/* 5. Terracotta Band: bold top band, sans-serif, numbered steps */
.card.t-terracotta {
  --bg: #fff5ef;
  --ink: #3d1c10;
  --accent: #c2410c;
  --rule: #f1cdb8;
  --head-font: "Trebuchet MS", Helvetica, Arial, sans-serif;
  --body-font: "Trebuchet MS", Helvetica, Arial, sans-serif;
  --pad: 0;
}
.card.t-terracotta .card-head {
  margin: 0;
  padding: 0.26in 0.24in 10px;
  background: #c2410c;
  border-bottom: none;
}
.card.t-terracotta .card-head h2 { color: #fff; font-size: 1.5em; }
.card.t-terracotta .card-desc,
.card.t-terracotta .card-meta { color: #ffe3d3; }
.card.t-terracotta .card-body,
.card.t-terracotta .card-foot { padding: 0 0.24in; }
.card.t-terracotta .card-body { padding-top: 10px; }
.card.t-terracotta .card-foot { margin-bottom: 0.2in; }
.card.t-terracotta .card-method ol { list-style: decimal; }
.card.t-terracotta .card-method li::marker { color: #c2410c; font-weight: 700; }

/* 6. Ocean Breeze: teal panels, two-column ingredient grid */
.card.t-ocean {
  --bg: #eaf6fb;
  --ink: #123040;
  --accent: #0e7490;
  --rule: #b6dbe8;
  --head-font: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
  --body-font: "Gill Sans", "Gill Sans MT", Calibri, sans-serif;
  --card-border: 1px solid #b6dbe8;
  --pad: 0.24in;
}
.card.t-ocean .card-head {
  padding: 6px 10px;
  margin: -2px -2px 10px;
  background: #0e7490;
  border-radius: 8px;
  border-bottom: none;
}
.card.t-ocean .card-head h2 { color: #f0fbff; }
.card.t-ocean .card-desc,
.card.t-ocean .card-meta { color: #cdeef8; }
.card.t-ocean .card-ing ul { display: grid; grid-template-columns: 1fr; }
.card.t-ocean .card-ing li { background: #ffffff; padding: 2px 6px; margin-bottom: 2px; border-radius: 4px; border: none; }
.card.t-ocean h3 { color: #0e7490; }

/* 7. Blush Script: soft pink, high-contrast serif headings, ornament rule */
.card.t-blush {
  --bg: #fdeef2;
  --ink: #4a2233;
  --accent: #b03a6b;
  --rule: #efc3d2;
  --head-font: Didot, "Bodoni 72", "Playfair Display", Georgia, serif;
  --body-font: Garamond, "EB Garamond", "Times New Roman", serif;
  --card-border: 1px solid #efc3d2;
  --radius-card: 18px;
  --pad: 0.3in;
}
.card.t-blush .card-head { text-align: center; border-bottom: none; }
.card.t-blush .card-head::after {
  content: "❦";
  display: block;
  margin-top: 4px;
  color: #b03a6b;
  font-size: 1em;
}
.card.t-blush .card-head h2 { font-style: italic; font-weight: 400; font-size: 1.6em; }
.card.t-blush .card-meta { justify-content: center; }
.card.t-blush .card-ing .q { color: #b03a6b; }

/* ---------- Print ---------- */
@page {
  size: 4in 6in;
  margin: 0;
}

@media print {
  html, body {
    background: none;
    margin: 0;
    padding: 0;
  }
  .no-print { display: none !important; }
  .print-stage {
    margin: 0;
    padding: 0;
    display: block;
  }
  .card {
    box-shadow: none;
    page-break-after: auto;
    break-inside: avoid;
  }
  .card-foot { max-height: none; }
  .card.t-sage, .card.t-terracotta, .card.t-ocean, .card.t-slate, .card.t-blush, .card.t-classic, .card.t-kraft {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
