/* CF Food Today. Mobile-first, Instagram-style layout. */

:root {
  --green: #74b143;
  --green-d: #5a9530;
  --green-l: #eef6e6;
  --ink: #262626;
  --ink-2: #4a4a4c;
  --muted: #737373;
  --line: #e4e4e4;
  --bg: #fafafa;
  --card: #fff;
  --high: #e8722a;
  --high-l: #fdf0e7;
  --light: #1b9688;
  --light-l: #e5f5f3;
  --both: #7a62c9;
  --both-l: #f1edfb;
  --danger: #d1323b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --top-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f2f2; --ink-2: #d6d6d6; --muted: #a0a0a0; --line: #303030;
    --bg: #0f0f0f; --card: #181818; --green-l: #1f2b17; --high-l: #2e1d12; --light-l: #102926; --both-l: #221c33;
    color-scheme: dark;
  }
  .brand img, .auth-logo, .about-logo { background: #fff; border-radius: 10px; padding: 4px 8px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
a { color: var(--green-d); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 800; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 700; color: var(--ink); }
.hp { position: absolute; left: -9999px; }
.inline { display: inline; }

.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.small .icon, .badge .icon, .chip .icon, .btn-sm .icon { width: 16px; height: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--green); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--green-d); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: .9rem; border-radius: 8px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--green-l); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-block { display: flex; width: 100%; margin: 16px 0; }
.iconbtn { background: none; border: 0; padding: 6px; color: var(--ink); cursor: pointer; border-radius: 50%; display: inline-flex; }
.iconbtn:hover { color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--green-d); font: inherit; font-weight: 700; cursor: pointer; }
.linkbtn-muted { color: var(--muted); font-weight: 600; }
.linkbtn-danger { color: var(--danger); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1040px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; gap: 16px; padding: 0 16px; }
.brand img { height: 34px; width: auto; }
.topsearch { flex: 1; max-width: 320px; display: none; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--muted); }
.topsearch input { border: 0; background: none; padding: 9px 0; font: inherit; width: 100%; color: var(--ink); outline: none; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.navlink { position: relative; display: inline-flex; flex-direction: column; align-items: center; color: var(--ink); padding: 6px 10px; border-radius: 10px; cursor: pointer; list-style: none; font-size: .72rem; font-weight: 700; }
.navlink::-webkit-details-marker { display: none; }
.navlink:hover { background: var(--bg); text-decoration: none; }
.navlink.is-active { color: var(--green-d); }
.navlink span { display: none; }
.topnav .navlink:not(.navlink-bell):not(summary) { display: none; }
.dot { position: absolute; top: 2px; right: 4px; background: var(--danger); color: #fff; font-size: .65rem; border-radius: 10px; padding: 0 5px; line-height: 16px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 200px; padding: 6px; z-index: 30; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; color: var(--ink); background: none; border: 0; font: inherit; border-radius: 8px; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg); text-decoration: none; }
.menu-pop .icon { width: 18px; height: 18px; }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.bottomnav a { color: var(--ink); padding: 4px 14px; display: flex; }
.bottomnav a.is-active { color: var(--green-d); }
.bottomnav .icon { width: 27px; height: 27px; }
.bottomnav a.is-active .icon { stroke-width: 2.6; }
.bottom-new { color: var(--green-d) !important; }

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .topsearch { display: flex; }
  .topnav .navlink:not(.navlink-bell):not(summary) { display: inline-flex; }
  .navlink span { display: block; }
}

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; background: #fff; border: 1px solid var(--line); flex: none; }
.avatar-xs { width: 26px; height: 26px; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 56px; height: 56px; }
.avatar-lg { width: 96px; height: 96px; }
.avatar-xl { width: 86px; height: 86px; }
@media (min-width: 768px) { .avatar-xl { width: 150px; height: 150px; } }

.who { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.who:hover { text-decoration: none; }
.who span { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.who-lg { margin-bottom: 18px; }

/* Layout */
.main { min-height: 70vh; }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px; }
.wrap-mid { max-width: 760px; }
.wrap-narrow { max-width: 600px; }
.layout-feed { max-width: 940px; margin: 0 auto; padding: 16px 0; display: flex; gap: 48px; justify-content: center; }
.feed-col { width: 100%; max-width: 480px; }
.side-col { display: none; width: 300px; padding-top: 12px; }
@media (min-width: 1000px) { .side-col { display: block; position: sticky; top: calc(var(--top-h) + 16px); align-self: flex-start; } }
@media (min-width: 520px) { .feed-col { padding: 0 8px; } }

.side-h { font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; margin: 20px 0 10px; }
.side-h a { color: var(--ink); font-size: .8rem; }
.side-thread { display: block; color: var(--ink); padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.side-note { margin-top: 24px; background: var(--green-l); border-radius: var(--radius); padding: 14px; font-size: .9rem; }
.side-note p { margin: 6px 0 0; }
.topic { display: block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--green-d); }

.footer { text-align: center; padding: 32px 16px 24px; border-top: 1px solid var(--line); margin-top: 32px; color: var(--ink-2); }
.footer p:first-child { display: flex; align-items: center; justify-content: center; gap: 8px; }
.footer img { border-radius: 6px; }

.flash { max-width: 600px; margin: 12px auto 0; padding: 12px 16px; border-radius: 12px; background: var(--green-l); color: var(--ink); font-weight: 600; }
.flash-info { background: var(--both-l); }
.errors { background: #fdeceb; color: #8e1d24; border-radius: 12px; padding: 10px 16px; margin-bottom: 16px; }
.errors ul { margin: 0; padding-left: 18px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* Hero (logged out) */
.hero { display: flex; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 12px 16px; }
.hero img { border-radius: 14px; flex: none; }
.hero h1 { font-size: 1.35rem; }
@media (min-width: 520px) { .hero { margin: 0 0 16px; } }

/* Chips, tabs, energy switch */
.feed-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 0 12px 14px; }
@media (min-width: 520px) { .feed-tools { padding: 0 0 14px; } }
.tabs { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs a { padding: 5px 14px; border-radius: 7px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.tabs a.is-on { background: var(--ink); color: var(--card); }
.tabs a:hover { text-decoration: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.scroll-x::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: .85rem; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip.is-on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.chip-high.is-on { background: var(--high); border-color: var(--high); color: #fff; }
.chip-light.is-on { background: var(--light); border-color: var(--light); color: #fff; }
.energy-switch { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.energy-help { color: var(--muted); display: inline-flex; }
.energy-help .icon { width: 20px; height: 20px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.badge-high { background: var(--high-l); color: var(--high); }
.badge-light { background: var(--light-l); color: var(--light); }
.badge-both { background: var(--both-l); color: var(--both); }
.badge-plain { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-weight: 700; }

/* Feed post */
.post { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
@media (min-width: 520px) { .post { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; } }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; }
.post-photo { display: block; position: relative; background: var(--bg); }
.post-photo .photo { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.post-photo .photo-none { aspect-ratio: 16 / 10; }
.kcal-pill { position: absolute; left: 12px; bottom: 12px; background: rgba(0,0,0,.66); color: #fff; font-weight: 800; padding: 4px 12px; border-radius: 999px; font-size: .9rem; backdrop-filter: blur(4px); }
.kcal-pill small { font-weight: 600; opacity: .8; margin-left: 2px; }
.post-body { padding: 4px 12px 14px; }
.post-title { font-size: 1.05rem; margin: 2px 0 4px; }
.post-title a { color: var(--ink); }
.post-desc { margin: 0 0 4px; color: var(--ink-2); }
.meta { font-size: .82rem; margin: 0; }
.meta a { color: var(--muted); }

.actions { display: flex; align-items: center; gap: 2px; margin-left: -6px; }
.actions form { display: contents; }
.actions .push { margin-left: auto; }
.actions .push button { margin-left: auto; }
.like.is-on { color: var(--danger); }
.like.is-on .icon, .save.is-on .icon { fill: currentColor; }
.like.pop .icon { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.3); } }
.counts { margin: 0 0 4px; font-size: .9rem; }

/* Placeholder photo when none uploaded */
.photo-none { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; text-align: center; padding: 20px; font-weight: 800; font-size: 1.2rem; width: 100%; height: 100%; aspect-ratio: 4 / 5; }
.photo-none .icon { width: 48px; height: 48px; opacity: .9; }
.photo-high { background: linear-gradient(135deg, #f6a04d, #e0612a); }
.photo-light { background: linear-gradient(135deg, #43c0a8, #16857a); }
.photo-both { background: linear-gradient(135deg, #9d8be0, #6a51bf); }
span.photo-none { padding: 0; aspect-ratio: auto; }
.photo-none:not(.photo-high):not(.photo-light):not(.photo-both) { background: var(--line); }

/* Grid tiles */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width: 768px) { .grid { gap: 6px; } }
.tile { position: relative; display: block; overflow: hidden; background: var(--line); aspect-ratio: 1; color: #fff; }
.tile .photo { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; }
.tile .photo-none { font-size: .8rem; padding: 8px; gap: 4px; aspect-ratio: 1; }
.tile .photo-none .icon { width: 26px; height: 26px; }
.tile-badge { position: absolute; top: 6px; right: 6px; }
.tile-badge .badge { box-shadow: 0 1px 3px rgba(0,0,0,.2); font-size: .62rem; padding: 2px 7px; }
.tile-over { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px; text-align: center; opacity: 0; transition: opacity .15s; font-size: .9rem; }
.tile-over .icon { width: 18px; height: 18px; fill: #fff; stroke: #fff; }
.tile:hover .tile-over, .tile:focus .tile-over { opacity: 1; text-decoration: none; }
@media (hover: none) { .tile-over { display: none; } }

.explore-search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; color: var(--muted); margin-bottom: 14px; }
.explore-search input { flex: 1; border: 0; background: none; padding: 12px 0; font: inherit; font-size: 1rem; outline: none; color: var(--ink); }
.explore-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.explore-filters .chips { margin: 0; }
.explore-filters .tabs { align-self: flex-start; }
.section-h { font-size: 1rem; margin: 22px 0 12px; }
.people-strip { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.people-strip a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); font-size: .8rem; font-weight: 700; }

.user-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }

/* Recipe page */
.recipe-top { display: grid; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
@media (min-width: 860px) { .recipe-top { grid-template-columns: 1.05fr 1fr; } }
.recipe-photo .photo { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 5; }
.recipe-side { padding: 4px 18px 18px; display: flex; flex-direction: column; }
.recipe-side .post-head { padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.recipe-title { font-size: 1.55rem; }
.recipe-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.recipe-desc { color: var(--ink-2); }
.tags a { font-weight: 700; margin-right: 6px; }

.nutrition { background: var(--bg); border-radius: 12px; padding: 14px; margin: 10px 0; }
.nutrition h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.nut-main { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; }
.nut-kcal { flex: none; text-align: center; background: var(--card); border: 3px solid var(--green); border-radius: 50%; width: 96px; height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nut-kcal strong { font-size: 1.6rem; line-height: 1; }
.nut-kcal span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.nut-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; margin: 0; flex: 1; font-size: .9rem; }
.nut-grid div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 2px 0; }
.nut-grid dt { color: var(--ink-2); }
.nut-grid dd { margin: 0; font-weight: 800; }
.nut-fat dd, .nut-salt dd { color: var(--green-d); }
.nut-note { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; color: var(--ink-2); }
.recipe-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 8px; }

.recipe-body { display: grid; gap: 20px; margin-top: 20px; }
@media (min-width: 860px) { .recipe-body { grid-template-columns: 1fr 1.4fr; } }
.ingredients, .method, .comments { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.ingredients ul { list-style: none; padding: 0; margin: 0; }
.ingredients li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.ingredients label { display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.ingredients input { accent-color: var(--green); }
.off-link { white-space: nowrap; color: var(--muted); }
.method ol { padding-left: 0; list-style: none; counter-reset: step; margin: 0; }
.method li { counter-increment: step; position: relative; padding: 0 0 14px 42px; }
.method li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.swaps { background: linear-gradient(90deg, var(--high-l), var(--light-l)); border-radius: 12px; padding: 14px; margin-top: 8px; }
.swaps h3 { font-size: 1rem; display: flex; align-items: center; gap: 4px; }
.swaps h3 .icon:first-child { color: var(--high); }
.swaps h3 .icon:nth-child(2) { color: var(--light); }

.comments { margin-top: 20px; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment p { margin: 0 0 2px; }
.comment-form { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.comment-form textarea { flex: 1; border: 0; background: none; font: inherit; resize: none; outline: none; padding: 8px 0; color: var(--ink); }
.grid-3 { margin-top: 8px; }

/* Forms */
.field { display: block; margin: 0 0 16px; border: 0; padding: 0; }
.field > span, .field legend, .field summary { display: block; font-weight: 800; margin-bottom: 6px; font-size: .92rem; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: .9rem; }
.check input { margin-top: 4px; accent-color: var(--green); }
.row-3 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
@media (min-width: 600px) { .row-3 { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input:not([type=checkbox]) { width: auto; flex: 1; min-width: 160px; }

.photo-pick { margin-bottom: 18px; }
.photo-drop { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; max-height: 360px; width: 100%; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; cursor: pointer; color: var(--muted); font-weight: 800; }
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-drop span { position: relative; z-index: 1; display: flex; gap: 6px; align-items: center; background: var(--card); padding: 6px 14px; border-radius: 999px; }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.energy-pick { display: grid; gap: 8px; }
@media (min-width: 600px) { .energy-pick { grid-template-columns: repeat(3, 1fr); } }
.energy-opt { display: block; cursor: pointer; }
.energy-opt input { position: absolute; opacity: 0; }
.energy-opt > span { display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; height: 100%; background: var(--card); }
.energy-opt strong { display: flex; align-items: center; gap: 6px; }
.energy-opt small { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.energy-opt-high input:checked + span { border-color: var(--high); background: var(--high-l); }
.energy-opt-light input:checked + span { border-color: var(--light); background: var(--light-l); }
.energy-opt-both input:checked + span { border-color: var(--both); background: var(--both-l); }
.energy-opt input:focus-visible + span { outline: 2px solid var(--green); }
.energy-opt-high strong .icon { color: var(--high); }
.energy-opt-light strong .icon { color: var(--light); }
.energy-opt-both strong .icon { color: var(--both); }

.ing-row { display: grid; grid-template-columns: 1fr 84px auto; gap: 6px; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.ing-row .ing-label { grid-column: 1 / -1; }
.ing-row .ing-find { white-space: nowrap; }
.ing-row .ing-remove { grid-row: 2; grid-column: 3; justify-self: end; }
.ing-row .ing-grams { grid-column: 1; grid-row: 2; width: 100%; max-width: 120px; }
.ing-row .ing-find { grid-column: 2; grid-row: 2; justify-self: start; }
.ing-match { grid-column: 1 / -1; color: var(--muted); }
.ing-match:empty { display: none; }
.ing-match.is-ok { color: var(--green-d); font-weight: 700; }
@media (min-width: 600px) {
  .ing-row { grid-template-columns: 1fr 90px auto auto; }
  .ing-row .ing-label { grid-column: 1; grid-row: 1; }
  .ing-row .ing-grams { grid-column: 2; grid-row: 1; }
  .ing-row .ing-find { grid-column: 3; grid-row: 1; }
  .ing-row .ing-remove { grid-column: 4; grid-row: 1; }
}
.nut-preview { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--card); padding: 10px 14px; border-radius: 12px; margin: 0 0 18px; font-size: .9rem; z-index: 5; }
@media (min-width: 768px) { .nut-preview { bottom: 12px; } }

/* Dialog sheets */
.sheet { border: 0; padding: 0; border-radius: 16px; width: min(420px, calc(100vw - 24px)); max-height: 80vh; background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.sheet-wide { width: min(620px, calc(100vw - 24px)); }
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 12px 18px; overflow-y: auto; max-height: 55vh; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.sheet-foot input { flex: 1; }
.book-opt { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 0; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.book-opt .icon { color: var(--muted); }
.book-opt.is-in .icon { color: var(--green-d); fill: currentColor; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-grid a, .share-grid button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font: inherit; font-weight: 700; background: none; cursor: pointer; }
.share-grid button { grid-column: 1 / -1; }
.off-search { display: flex; gap: 8px; padding: 12px 18px 0; }
.off-search input { flex: 1; }
#off-video { width: calc(100% - 36px); margin: 12px 18px 0; border-radius: 10px; background: #000; }
.off-results { min-height: 120px; }
.off-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 8px; background: none; border: 1px solid transparent; border-radius: 10px; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.off-item:hover { background: var(--bg); border-color: var(--line); }
.off-item img, .off-item .noimg { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.off-item small { display: block; color: var(--muted); }
.off-item b { font-size: .9rem; white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; }
.toast.is-on { opacity: 1; transform: translateX(-50%); pointer-events: auto; }

/* Login wall for logged-out visitors */
.wall { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: wall-in .3s ease; }
.wall[hidden] { display: none; }
.wall-box { background: var(--card); color: var(--ink); width: 100%; max-width: 420px; border-radius: 20px 20px 0 0; padding: 28px 24px calc(24px + env(safe-area-inset-bottom)); text-align: center; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
.wall-box img { margin: 0 auto 12px; border-radius: 16px; }
.wall-box .btn-block { margin: 18px 0 12px; }
@media (min-width: 600px) { .wall { align-items: center; } .wall-box { border-radius: 20px; } }
@keyframes wall-in { from { opacity: 0; } }
body.walled { overflow: hidden; }
body.walled .main, body.walled .footer { filter: blur(3px); pointer-events: none; user-select: none; }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: flex-start; padding: 8px 0 20px; }
@media (min-width: 768px) { .profile-head { gap: 64px; padding: 12px 40px 32px; } }
.profile-info { flex: 1; min-width: 0; }
.profile-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.profile-line h1 { font-size: 1.3rem; margin: 0; font-weight: 700; }
.profile-stats { display: flex; gap: 20px; list-style: none; padding: 0; margin: 0 0 12px; flex-wrap: wrap; }
.profile-stats a { color: var(--ink); }
.bio { white-space: normal; }
.profile-tabs { display: flex; justify-content: center; gap: 40px; border-top: 1px solid var(--line); margin-bottom: 12px; }
.profile-tabs a { display: flex; align-items: center; gap: 6px; padding: 12px 0; color: var(--muted); font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; border-top: 1px solid transparent; margin-top: -1px; }
.profile-tabs a.is-on { color: var(--ink); border-color: var(--ink); }
.profile-tabs .icon { width: 14px; height: 14px; }
.books { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (min-width: 768px) { .books { grid-template-columns: repeat(4, 1fr); } }
.book { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.book:hover { text-decoration: none; }
.book-cover { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--line); }
.book-cover img, .book-cover span { width: 100%; height: 100%; object-fit: cover; }
.book-new { border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px; justify-content: center; gap: 10px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.book-edit { margin-bottom: 16px; }
.avatar-pick { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }

.notif { display: flex; align-items: center; gap: 12px; padding: 10px 8px; color: var(--ink); border-radius: 10px; }
.notif:hover { background: var(--card); text-decoration: none; }
.notif.is-new { background: var(--green-l); }
.notif span { flex: 1; }
.notif-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

/* Community */
.threads { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.threads .empty { padding: 32px; }
.thread-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.thread-row:last-child { border-bottom: 0; }
.thread-row:hover { background: var(--bg); text-decoration: none; }
.thread-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-count { display: flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; }
.thread-count .icon { width: 18px; height: 18px; }
.thread-post { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.thread-post .post-head { padding: 0 0 12px; }
.thread-body { font-size: 1.02rem; margin-bottom: 8px; }
.reply { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.reply-form { margin-top: 16px; }

/* Auth */
.auth { max-width: 380px; margin: 32px auto; padding: 28px 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.auth form { text-align: left; }
.auth-logo { width: 180px; margin: 0 auto 16px; }

/* Prose pages */
.prose { font-size: 1.02rem; }
.prose h2 { margin-top: 1.6em; }
.about-logo { width: 200px; margin-bottom: 16px; }
.energy-cards { display: grid; gap: 12px; margin: 16px 0; }
@media (min-width: 700px) { .energy-cards { grid-template-columns: repeat(3, 1fr); } }
.energy-card { border-radius: var(--radius); padding: 16px; font-size: .95rem; }
.energy-card h3 { display: flex; gap: 6px; align-items: center; }
.energy-card-high { background: var(--high-l); } .energy-card-high h3 { color: var(--high); }
.energy-card-light { background: var(--light-l); } .energy-card-light h3 { color: var(--light); }
.energy-card-both { background: var(--both-l); } .energy-card-both h3 { color: var(--both); }
.callout { display: flex; gap: 10px; background: var(--green-l); border-radius: var(--radius); padding: 14px 16px; }

.danger-zone { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; }
.danger-zone summary { color: var(--danger); font-weight: 700; cursor: pointer; }
.report-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.report-row > span { flex: 1; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table td { padding: 8px 6px; border-bottom: 1px solid var(--line); }

@media print {
  .topbar, .bottomnav, .footer, .actions, .counts, .recipe-tools, .comments, .grid-3, .section-h, .nut-note { display: none !important; }
  body { background: #fff; }
  .recipe-top, .ingredients, .method { border: 0; }
  .recipe-photo .photo { max-height: 280px; aspect-ratio: auto; }
}

/* Announcement + featured strip */
.announce { background: var(--green); color: #fff; text-align: center; padding: 8px 16px; font-weight: 700; font-size: .92rem; }
.announce a { color: #fff; text-decoration: underline; }
.featured { margin: 0 12px 16px; }
@media (min-width: 520px) { .featured { margin: 0 0 16px; } }
.featured .section-h { margin-top: 0; }
.featured-strip { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.featured-strip::-webkit-scrollbar { display: none; }
.featured-item { flex: none; width: 120px; color: var(--ink); font-size: .8rem; font-weight: 700; line-height: 1.25; }
.featured-item .photo { width: 120px; height: 120px; aspect-ratio: 1; object-fit: cover; border-radius: 14px; margin-bottom: 6px; border: 3px solid var(--green); }
.featured-item .photo-none { font-size: 0; padding: 0; }
.featured-item .photo-none .icon { width: 32px; height: 32px; }

/* Admin area */
.admin { max-width: 1100px; }
.admin-head h1 { display: flex; align-items: center; gap: 8px; }
.admin-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.admin-nav a { padding: 10px 14px; color: var(--muted); font-weight: 800; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-nav a.is-on { color: var(--ink); border-color: var(--green); }
.admin-nav a:hover { text-decoration: none; color: var(--ink); }
.dot-inline { position: static; display: inline-block; }
.admin-alert { display: flex; align-items: center; gap: 8px; background: var(--high-l); color: var(--high); padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 800px) { .stat-grid { grid-template-columns: repeat(6, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stat strong { font-size: 1.8rem; line-height: 1.1; }
.admin-cols { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 860px) { .admin-cols { grid-template-columns: 1fr 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel h2 { font-size: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; padding: 5px 0; }
.bar-row b { text-align: right; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar i.bar-high { background: var(--high); } .bar i.bar-light { background: var(--light); } .bar i.bar-both { background: var(--both); }
.admin-search { display: flex; gap: 8px; margin-bottom: 10px; max-width: 520px; }
.table-wrap { overflow-x: auto; padding: 6px 10px; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 6px; border-bottom: 1px solid var(--line); }
.table td { vertical-align: middle; }
.table .who span { min-width: 140px; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form, .actions-cell a { margin-left: 4px; }
.thumb-cell { width: 56px; }
.thumb-cell .photo { width: 48px; height: 48px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.thumb-cell .photo-none { font-size: 0; padding: 0; gap: 0; }
.thumb-cell .photo-none .icon { width: 20px; height: 20px; }
.admin-pager { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.admin-settings h2 { margin-top: 10px; }
.admin-settings { max-width: 720px; }
.recipe-photo .photo-none { aspect-ratio: 16 / 9; }
@media (min-width: 860px) { .recipe-photo .photo-none { aspect-ratio: auto; min-height: 100%; } }
.stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 800px) { .stat-grid-4 { grid-template-columns: repeat(4, 1fr); } }
.chart { width: 100%; height: 180px; display: block; }
.chart-views { fill: var(--green); opacity: .35; }
.chart-visitors { fill: var(--green-d); }
.chart-legend { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.key-views { background: var(--green); opacity: .35; }
.key-visitors { background: var(--green-d); margin-left: 10px; }
.bar-row-wide { grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line); }
.tabs-sm a { padding: 4px 10px; font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hero-h { font-size: 1.35rem; }
