/* Тема «Вкусно Дома» из макета Recipe Platform.dc.html.
   Токены перенесены один в один: тёплый бежевый фон, мягкая зелень в
   акценте, глубокий зелёно-серый текст. Тёмная тема — из того же
   макета, а не выведена автоматически. */

:root {
  --bg: #fafaf5;
  --card: #ffffff;
  --elev: #ffffff;
  --alt: #f5f5dc;
  --accent: #a8e4a0;
  --on-accent: #243529;
  --ink: #243529;
  --ink2: #626b60;
  --line: #dfe5d9;
  --link: #356b42;
  --star: #e3a008;
  --danger: #b3261e;
  --r: 18px;
  --shadow: 0 1px 2px rgba(36, 53, 41, 0.06), 0 8px 24px rgba(36, 53, 41, 0.05);
  /* Заглушка вместо фото: диагональная штриховка из макета. */
  --ph1: #efefe2;
  --ph2: #f8f8f0;
  /* Высота нижней навигации. От неё считаются и отступ под контентом, и
     положение sticky-кнопки редактора — иначе «Продолжить» прячется за
     навигацией. */
  --nav-h: calc(56px + 22px + env(safe-area-inset-bottom));
}

html[data-theme="dark"] {
  --bg: #151c18;
  --card: #202a23;
  --elev: #2b372e;
  --alt: #2b372e;
  --accent: #a8e4a0;
  --ink: #f3f4e9;
  --ink2: #b6c0b2;
  --line: #3b493e;
  --link: #a8e4a0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  --ph1: #263127;
  --ph2: #2f3b31;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

a {
  color: var(--link);
  text-decoration: none;
}

/* Браузер красит текст кнопок и полей своим системным цветом (чёрным) и
   не наследует его от страницы. В светлой теме это незаметно, а в тёмной
   чёрный текст пропадает на тёмном фоне — поэтому наследуем явно. */
button,
input,
select,
textarea {
  color: inherit;
  font-family: inherit;
}

.placeholder {
  background: repeating-linear-gradient(135deg, var(--ph1) 0 10px, var(--ph2) 10px 20px);
}

/* ── раскладка ──────────────────────────────────────────────────────────── */

#screens {
  padding: 14px 14px calc(var(--nav-h) + 18px);
  min-height: 100dvh;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
}
.screen.active {
  display: flex;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.scroller::-webkit-scrollbar {
  display: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.muted {
  color: var(--ink2);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title {
  font: 700 17px Inter, sans-serif;
  letter-spacing: -0.01em;
}
.section-all {
  font: 600 12px Inter, sans-serif;
  color: var(--link);
  background: none;
  border: 0;
  cursor: pointer;
}

.screen-title {
  font: 700 20px Inter, sans-serif;
  letter-spacing: -0.01em;
}

/* ── поля и кнопки ──────────────────────────────────────────────────────── */

.field {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
}
.field input,
.field textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: 400 14px Inter, sans-serif;
  color: var(--ink);
  outline: none;
}
.field .icon {
  color: var(--ink2);
}

.input,
.textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  font: 400 14px Inter, sans-serif;
  color: var(--ink);
  outline: none;
}
.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.55;
}
.input:focus,
.textarea:focus,
.field:focus-within {
  border-color: var(--accent);
}

.label {
  font: 600 12px Inter, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink2);
  margin-bottom: 9px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 13px;
  font: 600 14px Inter, sans-serif;
  cursor: pointer;
}
.btn-accent {
  background: var(--accent);
  border: 0;
  color: var(--on-accent);
}
.btn-ghost {
  background: transparent;
}
.btn-danger {
  color: var(--danger);
}
.btn:active {
  transform: scale(0.99);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-wide {
  width: 100%;
  padding: 16px;
  font-size: 15px;
}
.btn-sm {
  padding: 9px 13px;
  font-size: 12px;
  border-radius: 11px;
}

/* Круглая кнопка от 44 px — размер зоны нажатия из макета. */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}

.square-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  flex: 0 0 auto;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 15px;
  font: 500 13px Inter, sans-serif;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}
.chip-removable {
  background: var(--alt);
  padding: 8px 11px 8px 13px;
  font-size: 12px;
}

.seg {
  display: flex;
  gap: 7px;
}
.seg button {
  flex: 1;
  text-align: center;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: 500 13px Inter, sans-serif;
  color: var(--ink);
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 600;
}

/* ── карточки рецептов ──────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.card-cover {
  position: relative;
  height: 150px;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.card-cover img,
.card-cover video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-cover .fav {
  position: absolute;
  top: 10px;
  right: 10px;
}
.card-badge {
  position: relative;
  font: 400 10px ui-monospace, monospace;
  color: var(--ink2);
  background: var(--card);
  border-radius: 6px;
  padding: 3px 6px;
}

.card-body {
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.card-title {
  font: 600 15px/1.3 Inter, sans-serif;
}
.card-meta {
  font: 400 13px Inter, sans-serif;
  color: var(--ink2);
}
.card-rating {
  font: 500 13px Inter, sans-serif;
  color: var(--ink2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stars {
  color: var(--star);
}

/* Компактная строка списка — поиск, избранное, подбор по продуктам. */
.row-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  cursor: pointer;
}
.row-card .thumb {
  position: relative;
  width: 92px;
  height: 78px;
  border-radius: 12px;
  flex: 0 0 auto;
  overflow: hidden;
}
.row-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.row-card .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.row-card .card-title {
  font-size: 14px;
}
.row-card .card-meta,
.row-card .card-rating {
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mini-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
}
.mini-card .cover {
  height: 96px;
  position: relative;
}
.mini-card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mini-card .body {
  padding: 10px;
}
.mini-card .card-title {
  font-size: 13px;
  margin-bottom: 4px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px;
}
.panel-title {
  font: 700 16px Inter, sans-serif;
}

.badge {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 5px 10px;
  font: 600 10px Inter, sans-serif;
}

/* ── карточка рецепта ───────────────────────────────────────────────────── */

.detail-cover {
  position: relative;
  height: 210px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  overflow: hidden;
}
.detail-cover img,
.detail-cover video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stat-row {
  display: flex;
  gap: 8px;
}
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}
.stat .k {
  font: 400 11px Inter, sans-serif;
  color: var(--ink2);
}
.stat .v {
  font: 600 14px Inter, sans-serif;
}

.media-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.media-strip::-webkit-scrollbar {
  display: none;
}
.media-thumb {
  position: relative;
  width: 120px;
  height: 88px;
  border-radius: 12px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
  overflow: hidden;
  cursor: pointer;
}
.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-thumb .play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.stepper button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--card);
  color: var(--ink);
  font: 600 15px Inter, sans-serif;
  cursor: pointer;
}
.stepper button.plus {
  background: var(--accent);
  color: var(--on-accent);
}
.stepper .value {
  font: 600 12px Inter, sans-serif;
  min-width: 66px;
  text-align: center;
}

.ingredient {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font: 400 14px Inter, sans-serif;
  cursor: pointer;
}
.ingredient:last-child {
  border-bottom: 0;
}
.ingredient input {
  accent-color: var(--accent);
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}
.ingredient .name {
  flex: 1;
}
.ingredient .amount {
  font-weight: 600;
}
.ingredient.checked .name {
  color: var(--ink2);
  text-decoration: line-through;
}

.step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 11px;
}
.step .n {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 12px Inter, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.step .text {
  font: 400 14px/1.6 Inter, sans-serif;
}

.star-pick {
  display: flex;
  gap: 7px;
}
.star-pick button {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--elev);
  color: var(--ink2);
  font-size: 20px;
  padding: 10px 0;
  cursor: pointer;
}
.star-pick button.on {
  background: var(--accent);
  border-color: transparent;
  color: var(--star);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--alt);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 11px Inter, sans-serif;
  color: var(--ink);
  flex: 0 0 auto;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-lg {
  width: 62px;
  height: 62px;
  font-size: 19px;
}

/* ── редактор рецепта ───────────────────────────────────────────────────── */

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.upload-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.upload-tile img,
.upload-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-tile .remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink2);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.upload-tile .status {
  position: absolute;
  left: 5px;
  bottom: 5px;
  font: 600 9px Inter, sans-serif;
  border-radius: 5px;
  padding: 3px 6px;
  background: var(--card);
  color: var(--ink2);
}
.upload-tile .status.ok {
  background: var(--accent);
  color: var(--on-accent);
}
.upload-tile .status.err {
  color: var(--danger);
}
.upload-add {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink2);
  background: var(--elev);
  cursor: pointer;
  font: 500 10px Inter, sans-serif;
}
.upload-add span:first-child {
  font-size: 18px;
}

.editor-line {
  display: flex;
  gap: 7px;
  align-items: center;
}
.editor-line .grow {
  flex: 1;
  min-width: 0;
}
.editor-line .w-amount {
  width: 62px;
  flex: 0 0 auto;
}
.editor-line .w-unit {
  width: 84px;
  flex: 0 0 auto;
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink2) 50%),
    linear-gradient(135deg, var(--ink2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 20px, calc(100% - 11px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

/* Sticky-кнопка редактора стоит над навигацией, а не под ней: nav
   зафиксирован у нижнего края, поэтому отсчитываем от его высоты. */
.sticky-action {
  position: sticky;
  bottom: var(--nav-h);
  margin: 14px -14px 0;
  padding: 12px 14px;
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 25;
}

/* ── шторка фильтров ────────────────────────────────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 24, 0.45);
  display: none;
  align-items: flex-end;
  z-index: 40;
}
.sheet.open {
  display: flex;
}
.sheet-body {
  width: 100%;
  background: var(--card);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 16px 16px calc(30px + env(safe-area-inset-bottom));
  max-height: 82dvh;
  overflow-y: auto;
}
.sheet-grip {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 0 auto 14px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.sheet-head .title {
  font: 700 18px Inter, sans-serif;
}
.chips-wrap {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* ── нижняя навигация ───────────────────────────────────────────────────── */

#nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  z-index: 30;
}
#nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--ink2);
  font: 500 10px Inter, sans-serif;
  cursor: pointer;
}
#nav button[aria-current="true"] {
  color: var(--link);
  font-weight: 600;
}
#nav .glyph {
  font-size: 15px;
}

/* ── состояния ──────────────────────────────────────────────────────────── */

.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
}
.empty .t {
  font: 600 15px/1.4 Inter, sans-serif;
  margin-bottom: 6px;
}
.empty .d {
  font: 400 13px/1.5 Inter, sans-serif;
  color: var(--ink2);
  margin-bottom: 12px;
}

.skeleton {
  border-radius: 16px;
  background: var(--ph1);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}

.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--link);
  animation: spin 1s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 14px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  padding: 10px 16px;
  font: 500 13px Inter, sans-serif;
  z-index: 60;
  display: none;
  max-width: 90vw;
  text-align: center;
}
#toast.show {
  display: block;
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .spinner {
    animation: none;
  }
}
