/* Визуальный язык взят из галереи (nolimit_gallery/public/styles.css):
   тёмный фон, золотая рамка, Space Grotesk / Space Mono, скруглённые плитки
   с пульсирующей рамкой и проезжающим бликом. */
:root {
  --ink: #0b0b0d;
  --surface: #151518;
  --surface-2: #1d1d22;
  --line: #2a2a31;
  --text: #ededee;
  --muted: #8b8b94;
  --muted-2: #61616a;
  --accent: #cda863;
  --danger: #d4756a;
  --frame: #c9a765;

  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --pad: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior: none;
}
body { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── Шапка ─────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  background: linear-gradient(var(--ink), rgba(11, 11, 13, 0.85));
  backdrop-filter: blur(8px);
}
#navbar { flex: 1; min-width: 0; display: flex; align-items: center; }
.role-badge {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid var(--line); border-radius: 100px; padding: 4px 10px; flex-shrink: 0;
}
.role-badge:empty { display: none; }

.book-title {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--text);
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb-back {
  appearance: none; background: none; border: none; color: var(--text);
  font-size: 26px; line-height: 1; padding: 2px 4px 2px 0; cursor: pointer; flex-shrink: 0;
}
.crumb-path {
  font-family: var(--font-mono); font-size: 13px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb-path b { color: var(--text); font-weight: 700; }

/* ── Контент ───────────────────────────────────────────── */
#content {
  flex: 1; padding: var(--pad);
  padding-bottom: calc(env(safe-area-inset-bottom) + 40px);
}
.section-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted-2); margin: 2px 0 14px;
}

/* ── Сетка плиток ──────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(3, 1fr); } }

.tile {
  position: relative; overflow: hidden; border-radius: 12px;
  border: 1px solid var(--frame); background: var(--surface-2);
  aspect-ratio: 3 / 4; cursor: pointer;
  animation: frame-pulse 2.4s ease-in-out infinite;
  opacity: 0; transform: translateY(12px) scale(0.97);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.tile.is-in { opacity: 1; transform: none; }
.tile:active { filter: brightness(1.12); }

@keyframes frame-pulse {
  0%, 100% { border-color: var(--frame); }
  50%      { border-color: rgba(201, 167, 101, 0.3); }
}

/* Блик, проезжающий по обложке — как в галерее */
@keyframes cover-shine {
  0%   { transform: translateX(-160%) rotate(9deg); }
  100% { transform: translateX(260%) rotate(9deg); }
}
.tile::after {
  content: ''; position: absolute; inset: -40% -60%; z-index: 3; pointer-events: none;
  background: linear-gradient(75deg, transparent 42%, rgba(255,255,255,0.16) 50%, transparent 58%);
  animation: cover-shine 6.5s ease-in-out infinite;
  animation-delay: var(--shine-delay, 0s);
}

.tile-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s ease;
}
.tile-img.loaded { opacity: 1; }
/* Плитка без фото: подложка из двух оттенков, цвет — от названия */
.tile-noimg {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, hsl(var(--h) 24% 22%), hsl(var(--h) 30% 12%));
}
.tile-noimg::before {
  content: attr(data-glyph);
  position: absolute; right: -6px; bottom: -10px;
  font-size: 84px; opacity: 0.12; line-height: 1;
}
.tile-overlay {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, transparent 40%, rgba(0,0,0,0.82) 100%);
}
.tile-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 10px 12px; }
.tile-name {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; color: #fff;
  line-height: 1.2; text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-meta {
  font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,0.62);
  margin-top: 4px; letter-spacing: 0.06em;
}
.tile-flag {
  position: absolute; top: 8px; left: 8px; z-index: 5;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  background: rgba(0,0,0,0.55); color: var(--danger);
  border: 1px solid rgba(212,117,106,0.5); border-radius: 100px; padding: 3px 8px;
}

/* ── Карточка рецепта ──────────────────────────────────── */
.recipe-hero {
  position: relative; height: 30vh; min-height: 180px;
  margin: calc(var(--pad) * -1) calc(var(--pad) * -1) 16px;
  overflow: hidden; background: var(--surface-2);
}
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 50%, var(--ink) 100%);
}
.recipe-title {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  line-height: 1.2; margin: 0 0 6px;
}
.recipe-meta {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  letter-spacing: 0.06em; margin-bottom: 20px;
}
.recipe-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--accent); border: 1px solid var(--line); border-radius: 100px; padding: 4px 10px;
}

.ing-list { list-style: none; padding: 0; margin: 0 0 24px; }
.ing-list li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.35;
}
.ing-list li::before { content: '·'; color: var(--accent); font-size: 18px; line-height: 1; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li {
  counter-increment: step; position: relative; padding: 0 0 18px 38px;
  font-size: 15px; line-height: 1.55;
}
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -1px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--frame); color: var(--accent);
  font-family: var(--font-mono); font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.raw-text { white-space: pre-wrap; font-size: 15px; line-height: 1.55; color: var(--text); }

.notice {
  border: 1px solid rgba(212,117,106,0.4); border-radius: 10px;
  background: rgba(212,117,106,0.08); padding: 12px 14px; margin-bottom: 18px;
  font-size: 14px; line-height: 1.45; color: var(--text);
}
.btn {
  appearance: none; margin-top: 10px; padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--frame); background: transparent; color: var(--accent);
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.06em; cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: default; }

/* ── Служебные состояния ───────────────────────────────── */
.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty .big { font-family: var(--font-display); font-size: 17px; color: var(--text); margin-bottom: 8px; }
.empty .small { font-size: 13px; line-height: 1.5; }

.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; gap: 10px;
}
.splash-mark {
  font-family: var(--font-display); font-weight: 600; letter-spacing: 0.42em;
  padding-left: 0.42em; font-size: 18px; color: var(--text);
}
.splash-sub { font-family: var(--font-mono); font-size: 12px; color: var(--muted-2); }
.splash.error .splash-sub { color: var(--danger); }
#splash-retry {
  margin-top: 16px; padding: 10px 20px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3); background: transparent; color: inherit;
  font: inherit; cursor: pointer;
}

/* ── Плитка подбора ────────────────────────────────────── */
.tile--action {
  background: linear-gradient(150deg, rgba(205,168,99,0.22), rgba(205,168,99,0.05));
  border-style: dashed;
}
.tile-action-glyph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 46px; opacity: 0.85; padding-bottom: 28px;
}

.tile-likes {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  font-family: var(--font-mono); font-size: 11px; color: #fff;
  background: rgba(0,0,0,0.5); border-radius: 100px; padding: 3px 8px;
}
.tile-flag--ok { color: var(--accent); border-color: rgba(205,168,99,0.5); }

/* ── Чипсы (сортировка, фильтры, разделы, правки) ──────── */
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; align-items: center; }
.chip--btn {
  appearance: none; background: transparent; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 100px; padding: 5px 11px;
}
.chip--btn.is-on { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.chip--danger { color: var(--danger); border-color: rgba(212,117,106,0.4); }
.edit-row { margin: -6px 0 18px; }

/* ── Лайк ──────────────────────────────────────────────── */
.like {
  appearance: none; cursor: pointer; margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 100px; padding: 4px 11px;
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
}
.like.is-on { border-color: rgba(212,117,106,0.55); }
.like:active { transform: scale(0.94); }

/* ── Экран подбора ─────────────────────────────────────── */
.hint { font-size: 13px; color: var(--muted-2); line-height: 1.45; margin: -8px 0 14px; }
.search {
  width: 100%; padding: 11px 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 15px;
}
.search::placeholder { color: var(--muted-2); }
.prod-group { margin-bottom: 18px; }
.prod-group[hidden] { display: none; }
.prod-group-t {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 8px;
}
.prod-row { display: flex; flex-wrap: wrap; gap: 7px; }
.prod {
  appearance: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 100px;
  color: var(--text); font: inherit; font-size: 14px; padding: 8px 14px;
}
.prod.is-on { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.prod[hidden] { display: none; }

/* Липкая нижняя кнопка: список продуктов длинный, а решение принимают внизу */
.bottom-bar {
  position: sticky; bottom: 0; z-index: 15;
  margin: 20px calc(var(--pad) * -1) calc(env(safe-area-inset-bottom) * -1);
  padding: 12px var(--pad) calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(rgba(11,11,13,0), var(--ink) 40%);
}
.btn--wide { width: 100%; margin: 0; padding: 14px; font-size: 14px; }

.title-input {
  width: 100%; margin: 0 0 6px; padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--frame); border-radius: 8px;
  color: var(--text); font-family: var(--font-display); font-size: 22px; font-weight: 700;
}

/* ── Плашка «Отменить» ─────────────────────────────────── */
.undo-bar {
  position: fixed; left: var(--pad); right: var(--pad);
  bottom: calc(env(safe-area-inset-bottom) + 16px); z-index: 900;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  animation: undo-in 0.25s ease;
}
@keyframes undo-in { from { opacity: 0; transform: translateY(12px); } }
.undo-btn {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--accent); font-family: var(--font-mono); font-size: 13px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* ── Форма рецепта ─────────────────────────────────────── */
.hdr-btn {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; flex-shrink: 0;
}
.tile--add { background: linear-gradient(150deg, rgba(127,179,138,0.18), rgba(205,168,99,0.06)); }

.ta {
  width: 100%; margin-bottom: 4px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; resize: vertical;
}
.ta::placeholder { color: var(--muted-2); }

.preview {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 8px;
  background: var(--surface);
}
.preview-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.preview-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.preview .ing-list { margin-bottom: 14px; }
.preview .steps li { padding-bottom: 12px; }

.bottom-bar--two { display: flex; gap: 8px; }
.bottom-bar--two .btn { flex: 1; margin: 0; padding: 14px; }
.btn--primary { background: var(--accent); color: var(--ink); font-weight: 700; }
.btn--primary:disabled { background: var(--surface-2); color: var(--muted-2); border-color: var(--line); }

.variant-note {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  margin-bottom: 6px; letter-spacing: 0.04em;
}
.author { font-family: var(--font-mono); }

/* ── Доступ ────────────────────────────────────────────── */
.user-list { display: flex; flex-direction: column; }
.user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.user-main { min-width: 0; }
.user-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); margin-top: 3px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .tile { opacity: 1 !important; transform: none !important; }
}
