:root {
  --bg: #fff5f8;
  --bg2: #ffe8f0;
  --card: #ffffff;
  --ink: #3a2430;
  --muted: #9a7384;
  --accent: #e0568c;
  --accent-dark: #c23a6e;
  --pink: #f4a4c0;
  --pink-soft: #ffe0eb;
  --line: #f3d4e0;
  --radius: 20px;
  --shadow: 0 4px 18px rgba(194, 58, 110, .08);
  --shadow-hover: 0 10px 28px rgba(194, 58, 110, .16);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(244, 164, 192, .45), transparent 55%),
    radial-gradient(ellipse 70% 45% at 95% 5%, rgba(224, 86, 140, .18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(255, 224, 235, .7), transparent 55%),
    linear-gradient(180deg, #fff8fb 0%, var(--bg) 40%, #fff5f8 100%);
  background-attachment: fixed;
}

/* ---------- Шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 248, 251, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1100px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .4em;
  color: var(--ink); text-decoration: none;
}
.logo-word { color: var(--accent-dark); }
.logo-initials {
  display: inline-block;
  font-family: var(--font-display);
  color: #fff;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 4px 12px 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f4a4c0 0%, #e0568c 55%, #d63d7a 100%);
  font-size: .88em;
  line-height: 1.2;
  box-shadow: 0 2px 10px rgba(214, 61, 122, .35);
}
.logo-initials--hero {
  font-size: clamp(18px, 3vw, 26px);
  padding: 8px 18px 9px;
  box-shadow: 0 6px 20px rgba(214, 61, 122, .32);
}

.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2;
}
#search {
  width: 100%; padding: 12px 40px 12px 42px;
  border: 1.5px solid var(--line); border-radius: 999px;
  font-size: 16px; font-family: var(--font-body);
  background: var(--card); color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 86, 140, .15);
}
#search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: var(--pink-soft); color: var(--accent-dark);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; display: none;
}

/* ---------- Герой ---------- */
.hero {
  margin: 28px 0 8px;
  animation: heroIn .55s ease-out both;
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.hero-copy {
  max-width: 1100px;
  margin: 0 auto 18px;
  padding: 0 20px;
}
.hero-brand {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 6.5vw, 56px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  color: var(--ink);
}
.hero-lead {
  color: var(--muted);
  margin-top: 14px;
  font-size: 17px;
  max-width: 34em;
  font-weight: 600;
}
.hero-visual {
  width: 100%;
  max-height: min(42vh, 420px);
  overflow: hidden;
  position: relative;
  background: #f8d0e0;
}
.hero-visual::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(255, 245, 248, .55) 100%);
  pointer-events: none;
}
.hero-visual img {
  display: block;
  width: 100%;
  height: min(42vh, 420px);
  object-fit: cover;
  object-position: center 40%;
  animation: heroImg .7s ease-out both;
}
@keyframes heroImg {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: none; }
}

/* ---------- Категории ---------- */
.cats {
  max-width: 1100px; margin: 24px auto 8px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
}
.cat {
  position: relative; border-radius: var(--radius); overflow: hidden;
  cursor: pointer; border: 3px solid transparent;
  aspect-ratio: 16 / 10; background: #f0d4de center/cover no-repeat;
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, border-color .2s;
}
.cat:hover { transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-hover); }
.cat.active { border-color: var(--accent); }
.cat::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 25%, rgba(58, 36, 48, .72));
}
.cat .cat-label {
  position: absolute; left: 12px; right: 8px; bottom: 9px; z-index: 2;
  color: #fff; font-weight: 700; font-size: 14.5px; line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.cat .cat-count {
  display: block; font-size: 11.5px; font-weight: 500; opacity: .88;
}

/* ---------- Панель результатов ---------- */
.bar {
  max-width: 1100px; margin: 22px auto 0; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.bar h2 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
}
.bar-actions { display: flex; align-items: center; gap: 10px; }
.bar .count { color: var(--muted); font-size: 14px; white-space: nowrap; font-weight: 600; }
.reset-btn {
  border: 1.5px solid var(--line); background: var(--card); color: var(--accent-dark);
  padding: 6px 14px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  display: none; font-weight: 700; font-family: var(--font-body);
  transition: background .15s, border-color .15s;
}
.reset-btn:hover { background: var(--pink-soft); border-color: var(--pink); }

/* ---------- Сетка рецептов ---------- */
.grid {
  max-width: 1100px; margin: 14px auto 40px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px;
}
.rcard {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease;
  display: flex; flex-direction: column;
  border: 1px solid rgba(243, 212, 224, .65);
}
.rcard:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.rcard .cover {
  height: 148px; display: flex; align-items: center; justify-content: center;
  font-size: 54px; position: relative; overflow: hidden;
}
.cover-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 1;
}
.cover-emoji { position: relative; z-index: 0; }
.rcard .cover .cat-chip {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  background: rgba(255,255,255,.9); backdrop-filter: blur(4px);
  font-size: 11px; font-weight: 700; color: var(--accent-dark);
  padding: 3px 10px; border-radius: 999px;
}
.rcard .body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rcard h3 {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em;
}
.rcard .meta { color: var(--muted); font-size: 12.5px; margin-top: auto; font-weight: 600; }
.rcard .meta .diff, .sheet-body .meta .diff {
  color: #c9a0b0; letter-spacing: 0.5px; font-size: 0.92em; font-weight: 500;
}
.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  padding: 60px 20px; font-size: 16px;
}
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* градиенты обложек по категориям — в розовой семье */
.g-novoe    { background: linear-gradient(135deg, #ffe4f0, #ffd0e4); }
.g-pp       { background: linear-gradient(135deg, #e8f6ee, #d4eedd); }
.g-zavtraki { background: linear-gradient(135deg, #fff0d6, #ffe0b8); }
.g-salaty   { background: linear-gradient(135deg, #e6f5dc, #d2ecc8); }
.g-zakuski  { background: linear-gradient(135deg, #ffe8dc, #ffd4c4); }
.g-supy     { background: linear-gradient(135deg, #ffe4d8, #ffcfc0); }
.g-myaso    { background: linear-gradient(135deg, #ffdcd8, #f5c0b8); }
.g-ryba     { background: linear-gradient(135deg, #dceef8, #c4e0f2); }
.g-pasta    { background: linear-gradient(135deg, #fef0d4, #f8e0b0); }
.g-garniry  { background: linear-gradient(135deg, #f5ebe0, #eadcc8); }
.g-vypechka { background: linear-gradient(135deg, #fce8d8, #f2d4bc); }
.g-deserty  { background: linear-gradient(135deg, #ffe0ee, #f8c4dc); }

/* ---------- Оверлей рецепта ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(58, 36, 48, .48); backdrop-filter: blur(4px);
  overflow-y: auto; padding: 24px 12px;
  animation: fadeOverlay .2s ease-out;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
.overlay.open { display: block; }
.sheet {
  max-width: 680px; margin: 0 auto; background: var(--card);
  border-radius: 24px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(58, 36, 48, .28);
  animation: pop .22s ease-out;
  border: 1px solid var(--line);
}
@keyframes pop { from { transform: translateY(16px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-cover {
  height: 220px; display: flex; align-items: center; justify-content: center;
  font-size: 76px; position: relative; overflow: hidden;
}
.sheet-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.92); font-size: 17px; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.sheet-close:hover { background: #fff; }
.sheet-body { padding: 24px 28px 30px; }
.sheet-body .cat-line {
  color: var(--accent); font-weight: 800; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .07em;
}
.sheet-body h2 {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 800; letter-spacing: -.02em;
  margin: 6px 0 4px; line-height: 1.2;
}
.sheet-body .meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; font-weight: 600; }
.sheet-actions { display: flex; gap: 10px; margin: 4px 0 18px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 999px; padding: 10px 20px; font-size: 14.5px;
  font-weight: 700; cursor: pointer; font-family: var(--font-body);
  transition: background .15s, transform .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost {
  background: var(--pink-soft); color: var(--ink);
  border: 1.5px solid var(--line);
}

/* содержимое рецепта */
.rbody h3 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 18px 0 8px; font-weight: 800;
}
.rbody h4 { margin: 14px 0 6px; font-size: 15.5px; font-family: var(--font-display); }
.rbody ul.ing { list-style: none; }
.rbody ul.ing > li {
  padding: 7px 0; border-bottom: 1px dashed var(--line);
  display: flex; align-items: flex-start; gap: 10px; font-size: 15px;
}
.rbody ul.ing > li > .ing-text {
  flex: 1; min-width: 0; /* текст одним блоком — не рвётся на колонки из‑за <em> */
}
.rbody ul.ing > li > .ing-text > ul {
  list-style: disc; margin: 6px 0 0 1.1em; padding: 0;
}
.rbody ul.ing > li > .ing-text > ul > li {
  padding: 3px 0; border: none; display: list-item; font-size: 14.5px;
}
.rbody ul.ing li input[type=checkbox] {
  width: 19px; height: 19px; margin-top: 2px; flex-shrink: 0;
  accent-color: var(--accent); cursor: pointer;
}
.rbody ul.ing > li.checked { color: var(--muted); }
.rbody ul.ing > li.checked > .ing-text { text-decoration: line-through; }
.rbody ol.steps { padding-left: 0; counter-reset: st; list-style: none; }
.rbody ol.steps li {
  counter-increment: st; position: relative;
  padding: 8px 0 8px 42px; font-size: 15px;
}
.rbody ol.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 8px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--pink-soft); color: var(--accent-dark);
  font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.rbody .note {
  background: var(--pink-soft); border-left: 3px solid var(--accent);
  padding: 10px 14px; font-size: 14px; margin-top: 16px; border-radius: 0 12px 12px 0;
}
.rbody .variant { margin-top: 10px; }

.rbody .step-shot {
  margin: 12px 0 8px 0; padding: 0; border-radius: 14px; overflow: hidden;
  background: #fceef4; border: 1px solid var(--line);
}
.rbody .step-shot img {
  display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover;
}
.rbody .step-shot figcaption {
  font-size: 13px; color: var(--muted); padding: 8px 12px 10px; line-height: 1.35; font-weight: 600;
}
@media (max-width: 640px) {
  .rbody .step-shot img { max-height: 160px; }
}

/* ---------- Подвал ---------- */
footer {
  border-top: 1px solid var(--line); padding: 26px 20px 40px;
  max-width: 1100px; margin: 0 auto; color: var(--muted); font-size: 13.5px;
}
footer a { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.foot-doc { margin-top: 8px; }
.brand-foot {
  margin-top: 16px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: .45em;
  font-size: 15px;
}
.brand-foot .logo-initials { font-size: .9em; }

/* ---------- Кнопка наверх ---------- */
#toTop {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #f4a4c0, var(--accent));
  color: #fff; font-size: 20px;
  box-shadow: var(--shadow-hover); display: none;
  transition: transform .15s;
}
#toTop:hover { transform: translateY(-2px); }

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 640px) {
  .top-inner { padding: 10px 14px; gap: 10px; }
  .logo { font-size: 16px; }
  .hero { margin-top: 18px; }
  .hero-copy { padding: 0 14px; margin-bottom: 14px; }
  .hero-title { font-size: clamp(28px, 9vw, 40px); }
  .hero-lead { font-size: 15px; }
  .hero-visual, .hero-visual img { height: min(32vh, 260px); max-height: min(32vh, 260px); }
  .cats { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 9px; padding: 0 14px; }
  .cat .cat-label { font-size: 12.5px; left: 9px; bottom: 7px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 11px; padding: 0 14px; }
  .rcard .cover { height: 110px; font-size: 42px; }
  .sheet-cover { height: 160px; }
  .rcard h3 { font-size: 14.5px; }
  .bar { padding: 0 14px; }
  .sheet-body { padding: 20px 18px 26px; }
  .overlay { padding: 12px 6px; }
}

/* ---------- Печать: только открытый рецепт ---------- */
@media print {
  body.print-recipe > *:not(.overlay) { display: none !important; }
  body.print-recipe .overlay { position: static; background: none; padding: 0; display: block; overflow: visible; }
  body.print-recipe .sheet { box-shadow: none; border-radius: 0; max-width: none; border: 0; }
  body.print-recipe .sheet-cover { height: 70px; font-size: 44px; }
  body.print-recipe .sheet-close, body.print-recipe .sheet-actions { display: none !important; }
  body.print-recipe .rbody ul.ing li input { display: none; }
  body.print-recipe .rbody ul.ing > li { display: block; padding-left: 0; }
}
