:root {
  --canvas: #F4F3F1;
  --card: #FFFFFF;
  --ink: #1C1A1B;
  --ink-soft: #6B6669;
  --line: #E4E2DF;
  --accent: #B03A5B;
  --accent-soft: #FBEEF2;
  --on-accent: #FFFFFF;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 26, 27, .05), 0 6px 20px rgba(28, 26, 27, .06);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #17161A;
    --card: #201E23;
    --ink: #EFECEE;
    --ink-soft: #9C959B;
    --line: #302D34;
    --accent: #F1849F;
    --accent-soft: #331F27;
    --on-accent: #17161A;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  text-decoration: none; color: var(--ink);
}
.brand-mark { font-size: 1.4rem; }
.brand-name { font-family: var(--serif); font-size: 1.25rem; letter-spacing: -.01em; }

.topbar-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: .5rem;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .9rem;
}
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; background: none; outline: none; width: 11rem; max-width: 40vw; }
.search:focus-within { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 999px;
  padding: .5rem 1.1rem;
  font-weight: 600;
  font-size: .92rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn[disabled] { opacity: .55; cursor: default; filter: none; }

/* ---------- layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}
main:focus { outline: none; }

.page-head { margin-bottom: 1.8rem; }
.page-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.page-head p { color: var(--ink-soft); margin-top: .4rem; }

/* ---------- recipe grid ---------- */
.grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(28,26,27,.06), 0 14px 32px rgba(28,26,27,.10); }

.card-top {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  font-size: 3.4rem;
  line-height: 1;
  position: relative;
}
.card-cooked {
  position: absolute;
  top: .6rem; right: .6rem;
  background: rgba(255,255,255,.92);
  color: #1C1A1B;
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 600;
}
.card-body { padding: .95rem 1.05rem 1.15rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.card-body h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -.01em;
  line-height: 1.25;
}
.card-body .blurb { color: var(--ink-soft); font-size: .88rem; flex: 1; }
.card-meta {
  display: flex; gap: .5rem; flex-wrap: wrap;
  font-size: .78rem; color: var(--ink-soft);
  margin-top: .45rem;
}
.card-meta span:not(:last-child)::after { content: " ·"; }

/* ---------- recipe detail ---------- */
.back {
  display: inline-block;
  font-size: .9rem;
  text-decoration: none;
  margin-bottom: 1.2rem;
  color: var(--ink-soft);
}
.back:hover { color: var(--accent); }

.hero {
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: clamp(3.5rem, 12vw, 5.5rem);
  line-height: 1;
  padding: clamp(1.8rem, 6vw, 3rem);
  margin-bottom: 1.5rem;
}

.recipe-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5.5vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.08;
}
.recipe-head .blurb { color: var(--ink-soft); margin-top: .5rem; max-width: 55ch; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .25rem .7rem;
  font-size: .8rem;
  color: var(--ink-soft);
}
.chip strong { color: var(--ink); font-weight: 600; }

.cols {
  display: grid;
  gap: 1.6rem;
  margin-top: 2rem;
  align-items: start;
}
@media (min-width: 820px) {
  .cols { grid-template-columns: 20rem 1fr; gap: 2.4rem; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem 1.4rem;
  box-shadow: var(--shadow);
}
.panel h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: .3rem;
}
.panel .hint { font-size: .8rem; color: var(--ink-soft); margin-bottom: .9rem; }
.group-name {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 1.1rem 0 .5rem;
}
.group-name:first-of-type { margin-top: 0; }

.tick {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  padding: .42rem 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.tick input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: none;
  width: 19px; height: 19px;
  margin-top: .18rem;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  display: grid;
  place-items: center;
  transition: background .14s ease, border-color .14s ease;
}
.box::after {
  content: "";
  width: 9px; height: 5px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) scale(0);
  transition: transform .14s ease;
  margin-top: -2px;
}
.tick input:checked + .box { background: var(--accent); border-color: var(--accent); }
.tick input:checked + .box::after { transform: rotate(-45deg) scale(1); }
.tick input:checked ~ .tick-text { color: var(--ink-soft); text-decoration: line-through; }
.tick input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.tick-text { transition: color .14s ease; }

.step { align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.step:last-of-type { border-bottom: 0; }
.step-n {
  flex: none;
  width: 1.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
  font-size: .88rem;
  margin-top: .16rem;
}
.step input:checked ~ .step-body { color: var(--ink-soft); }
.step input:checked ~ .step-n { opacity: .45; }

.progress {
  height: 6px;
  background: var(--canvas);
  border-radius: 999px;
  overflow: hidden;
  margin: .3rem 0 1.1rem;
  border: 1px solid var(--line);
}
.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0;
  transition: width .28s ease;
}

.done-note {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: .9rem 1rem;
  margin-top: 1.2rem;
  font-size: .92rem;
}

.made {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.made .tally { font-size: .88rem; color: var(--ink-soft); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }
.pop { animation: pop .34s ease; }

/* ---------- form ---------- */
form { display: flex; flex-direction: column; gap: 1.1rem; max-width: 44rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .85rem; font-weight: 600; }
.field .help { font-size: .8rem; color: var(--ink-soft); font-weight: 400; }
.field input, .field textarea {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .8rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
.row { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
@media (min-width: 620px) { .row { grid-template-columns: 1fr 1fr; } }

.picker { display: flex; gap: .4rem; flex-wrap: wrap; }
.picker button {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 2.6rem; height: 2.6rem;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid; place-items: center;
}
.picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.picker.colors button { border-radius: 999px; }
.picker.colors span { display: block; width: 100%; height: 100%; border-radius: 999px; }

.notice { border-radius: 10px; padding: .75rem .9rem; font-size: .9rem; }
.notice.bad { background: var(--accent-soft); color: var(--accent); }
.notice.good { background: var(--accent-soft); }

.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--ink-soft);
}
.empty .big { font-size: 2.6rem; display: block; margin-bottom: .6rem; }

.foot {
  border-top: 1px solid var(--line);
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
  font-size: .82rem;
  color: var(--ink-soft);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
