:root {
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #2c2421;
    --muted: #8a7f76;
    --accent: #d97742;
    --accent-dark: #b85e30;
    --border: #ece5dc;
    --danger: #c0392b;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* Шапка */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.logo { font-size: 1.3rem; font-weight: 700; text-decoration: none; color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-badge { color: var(--muted); font-size: .9rem; font-weight: 600; }

/* Вход */
.login-form { max-width: 420px; }
.login-hint { color: var(--muted); font-size: .9rem; margin: 4px 0 20px; }

/* Кнопки */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; border: none;
    font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* Уведомления */
.flash { padding: 12px 16px; border-radius: 8px; margin: 16px 0; }
.flash-success { background: #e6f4ea; color: #2e7d32; }
.flash-error { background: #fdecea; color: var(--danger); }

/* Поиск и фильтры */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 16px; }
.search-bar input[type=search] { flex: 1; min-width: 200px; }
.search-bar input, .search-bar select {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; background: #fff;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tag {
    font-size: .85rem; padding: 4px 10px; background: #fff; border: 1px solid var(--border);
    border-radius: 20px; text-decoration: none; color: var(--muted);
}
.tag:hover, .tag-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Сетка карточек */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.recipe-card {
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); text-decoration: none; color: var(--text);
    transition: transform .15s, box-shadow .15s;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.card-img { height: 160px; background: #f0e9e0; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; opacity: .4; }
.card-body { padding: 14px; }
.card-body h3 { margin: 0 0 8px; font-size: 1.1rem; }
.card-desc { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

.badge { display: inline-block; background: #f0e9e0; color: var(--accent-dark); padding: 2px 8px; border-radius: 6px; font-size: .8rem; margin-right: 6px; }
.meta { color: var(--muted); font-size: .85rem; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .btn { margin-top: 16px; }

/* Детальная страница */
.recipe-detail { background: var(--card); border-radius: var(--radius); padding: 28px; margin: 24px 0; box-shadow: var(--shadow); }
.back-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.detail-header { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.detail-header h1 { margin: 0; }
.detail-actions { display: flex; gap: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.detail-img { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); margin: 16px 0; }
.detail-desc { font-size: 1.05rem; color: #5a4f48; }
.detail-columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 32px; margin-top: 20px; }
.servings-control { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: .9rem; }
.servings-control input { width: 60px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; text-align: center; font-size: .95rem; }
.serv-btn { width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--accent-dark); }
.serv-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.detail-ingredients .qty { font-weight: 600; }
.detail-ingredients ul { padding-left: 20px; }
.detail-ingredients li, .detail-steps li { margin-bottom: 8px; }
.detail-steps ol { padding-left: 20px; }
.steps-progress { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.step-checklist { list-style: decimal; padding-left: 22px; }
.step-checklist li { margin-bottom: 10px; }
.step-checklist label { display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.step-checklist input { flex: none; transform: scale(1.25); cursor: pointer; }
.step-checklist li.done .step-text { text-decoration: line-through; color: var(--muted); }
#reset-steps { margin-top: 4px; }

/* Форма */
.recipe-form { background: var(--card); border-radius: var(--radius); padding: 28px; margin: 24px 0; box-shadow: var(--shadow); max-width: 700px; }
.recipe-form label { display: block; margin-bottom: 16px; font-weight: 600; font-size: .9rem; }
.recipe-form input, .recipe-form textarea, .recipe-form select {
    display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; font-family: inherit; font-weight: 400;
}
.recipe-form textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-preview { max-width: 200px; border-radius: 8px; margin: 8px 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

@media (max-width: 640px) {
    .detail-columns, .form-row { grid-template-columns: 1fr; }
}

/* Навигация */
.site-nav { display: flex; gap: 16px; margin-right: auto; margin-left: 24px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 600; }
.site-nav a:hover { color: var(--accent-dark); }

.page-title { margin: 24px 0 8px; }
.muted-note { color: var(--muted); font-size: .9rem; }

/* Список меню */
.menu-create {
    display: flex; gap: 14px; align-items: end; flex-wrap: wrap;
    background: var(--card); border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); margin: 16px 0 24px;
}
.menu-create label { font-weight: 600; font-size: .85rem; color: var(--muted); }
.menu-create input {
    display: block; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: .95rem; font-family: inherit;
}
.menu-create input[type=text] { min-width: 260px; }

.menu-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.menu-list-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--card); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
}
.menu-list-link { text-decoration: none; color: var(--text); display: grid; gap: 2px; }
.menu-list-link strong { font-size: 1.05rem; }

/* Сетка недели */
.menu-detail { background: var(--card); border-radius: var(--radius); padding: 28px; margin: 24px 0; box-shadow: var(--shadow); }
.week-grid { display: grid; gap: 14px; margin-top: 20px; }
.week-day { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.week-day-title { margin: 0 0 10px; font-size: 1rem; }
.week-day-title .meta { font-weight: 400; }
.week-meals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.week-cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cell-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.dish { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.dish-name { display: block; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; word-break: break-word; }
.dish-name:hover { color: var(--accent-dark); }
.dish-controls { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.dish-controls select {
    padding: 3px 6px; border: 1px solid var(--border); border-radius: 6px;
    font-size: .8rem; background: #fff; color: var(--muted);
}
.dish-remove {
    border: none; background: transparent; color: var(--muted); cursor: pointer;
    font-size: 1.2rem; line-height: 1; padding: 0 4px;
}
.dish-remove:hover { color: var(--danger); }
.cell-add {
    align-self: start; font-size: .85rem; color: var(--accent-dark); text-decoration: none;
    border: 1px dashed var(--border); border-radius: 8px; padding: 5px 10px;
}
.cell-add:hover { border-color: var(--accent); background: var(--bg); }

/* Выбор блюда */
.pick-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.pick-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    background: var(--card); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow);
}
.pick-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pick-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; }
.pick-thumb-empty { display: flex; align-items: center; justify-content: center; background: #f0e9e0; font-size: 1.5rem; opacity: .5; }
.pick-title { font-weight: 600; color: var(--text); text-decoration: none; }
.pick-title:hover { color: var(--accent-dark); }
.pick-add { display: flex; gap: 8px; align-items: center; }
.pick-add select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; background: #fff; }

/* Список покупок */
.shopping { background: var(--card); border-radius: var(--radius); padding: 28px; margin: 24px 0; box-shadow: var(--shadow); }
.shop-list { list-style: none; padding: 0; margin: 16px 0 0; }
.shop-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; border-bottom: 1px solid var(--border);
}
.shop-check { display: flex; align-items: baseline; gap: 10px; cursor: pointer; flex: 1; min-width: 0; }
.shop-check input { flex: none; transform: scale(1.2); cursor: pointer; }
.shop-text { word-break: break-word; }
.shop-row.bought .shop-text { text-decoration: line-through; color: var(--muted); }
.shop-from {
    color: var(--muted); font-size: .8rem; text-align: right; flex: none;
    max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shop-remove, .shop-restore {
    border: none; background: transparent; color: var(--muted); cursor: pointer;
    font-size: 1.2rem; line-height: 1; padding: 0 4px;
}
.shop-remove:hover { color: var(--danger); }
.shop-restore:hover { color: var(--accent-dark); }
.shop-row-off .shop-text { color: var(--muted); text-decoration: line-through; }
.shop-row-off { flex: 1; }
.shop-add { display: flex; gap: 8px; margin-top: 18px; }
.shop-add input {
    flex: 1; padding: 9px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: .95rem; font-family: inherit;
}
.shop-hidden { margin-top: 22px; color: var(--muted); }
.shop-hidden summary { cursor: pointer; font-size: .9rem; }

@media print {
    .site-header, .site-footer, .no-print, .flash, .shop-from { display: none !important; }
    .shopping { box-shadow: none; padding: 0; }
    body { background: #fff; }
}

@media (max-width: 700px) {
    .week-meals { grid-template-columns: 1fr; }
    .site-nav { margin-left: 0; gap: 12px; width: 100%; order: 3; }
    .shop-from { display: none; }
}

/* Пометка происхождения рецепта */
.badge-own { background: #e6f0e8; color: #2e7d32; }
.badge-shared { background: #e8eef6; color: #35618e; }

.origin-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
    font-size: .85rem; padding: 5px 14px; background: #fff; border: 1px solid var(--border);
    border-radius: 20px; text-decoration: none; color: var(--muted); font-weight: 600;
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip-active { background: var(--accent); color: #fff; border-color: var(--accent); }

.origin-set { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.origin-set .btn { padding: 5px 12px; font-size: .85rem; }

/* Число едоков в меню */
.people-control { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 16px; }
.people-control label { font-weight: 600; font-size: .95rem; }
.people-control select {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: .95rem; background: #fff; margin: 0 4px;
}

/* Блюдо без рецепта */
.custom-dish {
    display: flex; align-items: end; gap: 12px; flex-wrap: wrap;
    background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
    padding: 14px 18px; margin: 16px 0;
}
.custom-dish label { font-weight: 600; font-size: .85rem; color: var(--muted); flex: 1; min-width: 240px; }
.custom-dish input {
    display: block; width: 100%; margin-top: 6px; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; font-family: inherit;
}
.dish-plain { border-left: 3px solid var(--border); }
.dish-tag {
    display: inline-block; margin-top: 4px; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); background: #fff;
    border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}
.shop-warning { border-left: 3px solid var(--accent); padding-left: 12px; }
