/* Hôm Nay Nấu Gì. Quy tắc: DESIGN.md */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --text: #2d2a26;
  --muted: #6b645c;
  --line: #ebe4da;
  --accent: #d95d39; /* chỉ trang trí */
  --primary: #b4421f; /* chữ và nút, đủ tương phản */
  --primary-ink: #ffffff;
  --primary-soft: #fbe6dd;
  --herb: #437352;
  --herb-soft: #e6f0e8;
  --k-de: #437352; --k-vua: #96610f; --k-kho: #b4421f; /* màu theo độ khó */
  --radius: 18px;
  --shadow: 0 1px 2px rgba(45, 42, 38, .05), 0 8px 24px rgba(45, 42, 38, .07);
  --fs: 17px;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d1a17; --surface: #27231f; --surface-2: #322c27; --text: #f3ede6; --muted: #bdb3a8; --line: #3e3730;
  --accent: #f08a62; --primary: #f39a74; --primary-ink: #2a1208; --primary-soft: #47291d; --herb: #92cfa2; --herb-soft: #24362a; --k-de: #92cfa2; --k-vua: #e3b660; --k-kho: #f39a74;
  --shadow: none; color-scheme: dark;
}
:root[data-big] { --fs: 20px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs)/1.6 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 1.3em 0 .5em; }
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.9em; margin-top: .4em; }
h2 { font-size: 1.35em; }
h3 { font-size: 1em; }
img { max-width: 100%; height: auto; }
button, select { font: inherit; color: inherit; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.lead { font-size: 1.08em; color: var(--muted); margin-top: 0; }
.kicker { margin: 4px 0 -10px; font-size: .85em; font-weight: 600; color: var(--primary); }
.kicker a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ic { width: 22px; height: 22px; flex: none; }

/* Thanh trên, thanh dưới */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px; padding-top: calc(8px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; min-height: 44px; gap: 10px; color: var(--text); text-decoration: none; font: 700 1.15em var(--serif); }
.topbar-actions { display: flex; gap: 2px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--muted); border-radius: 12px; cursor: pointer; display: grid; place-items: center; font-size: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
a.icon-btn{font-size:15px;font-weight:700;text-decoration:none}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; min-height: 58px; font-size: 13px; color: var(--muted); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.tabbar a[aria-current="page"] .ic { background: var(--primary-soft); border-radius: 999px; padding: 2px 12px; width: 48px; }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: 13px; line-height: 20px; text-align: center; }
@media (min-width: 900px) { .tabbar { max-width: 640px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); } }

/* Nút, ô nhập, chip */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 14px; background: var(--primary); color: var(--primary-ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.big { min-height: 56px; font-size: 1.05em; padding: 0 26px; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn[aria-pressed="true"].ghost { background: var(--primary); color: var(--primary-ink); }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; color: var(--muted); margin: 10px 0; }
.search input { flex: 1; border: 0; background: none; min-height: 52px; font: inherit; color: var(--text); min-width: 0; }
.search input:focus { outline: none; }
.search:focus-within { outline: 3px solid var(--primary); }
.search.big { box-shadow: var(--shadow); }
.search.big input { min-height: 58px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip a { color: inherit; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 12px; max-width: 100%; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 10px; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.seg.small button { min-height: 44px; padding: 6px 12px; font-size: .9em; }
.seg .ic { width: 18px; height: 18px; }
select { min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); width: 100%; }
.tag { display: inline-flex; align-items: center; min-height: 44px; font-size: .85em; padding: 0 14px; border-radius: 999px; background: var(--herb-soft); color: var(--herb); text-decoration: none; margin: 2px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin: 20px 0; }
.crumbs { font-size: .85em; color: var(--muted); margin-top: 2px; }
.crumbs a, .footer-links a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 2em; }
.sec-head h2 { margin: 0 0 .6em; line-height: 1.15; }
.sec-head a { font-weight: 600; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; }

.hero h1 { font-size: 2.05em; margin: .2em 0 .5em; }
.spin h2 { margin-top: 0; font-size: 1.6em; padding-right: 40px; }
.spin-am { position: absolute; top: 10px; right: 10px; }
/* Dùng chung: ẩn, màu độ khó, danh mục. Khung quay món ở home.css */
[hidden] { display: none !important; }
.k-de { --k: var(--k-de); } .k-vua { --k: var(--k-vua); } .k-kho { --k: var(--k-kho); }
.cat-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.cat-row .cat-card { flex: 0 0 132px; }
.cat-row .rcard { flex: 0 0 168px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 16px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .2s; }
@media (hover: hover) and (pointer: fine) { .cat-card:hover, .rcard:hover { transform: translateY(-2px); } .cat-card:hover { border-color: var(--accent); } }
.cat-card img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; }
.cat-card span:last-child { color: var(--muted); font-size: .82em; }
.cat-emoji { width: 72px; height: 72px; border-radius: 50%; background: var(--primary-soft); display: grid; place-items: center; font-size: 36px; }
.cat-emoji.big { width: 96px; height: 96px; font-size: 48px; flex: none; }
.cat-head { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.cat-head img { border-radius: 50%; object-fit: cover; }
.cat-head h1 { margin: 0 0 4px; }
.fridge-cta { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--herb-soft); border-color: transparent; }
.fridge-cta h2 { margin: 0 0 4px; color: var(--herb); }
.fridge-cta p { margin: 0; }
.fridge-cta .btn { background: var(--herb); color: var(--primary-ink); }

/* Thẻ món */
.rgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 700px) { .rgrid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .rgrid { grid-template-columns: repeat(4, 1fr); } }
.rcard { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 3px solid var(--k, var(--line)); }
.rcard-img { position: relative; aspect-ratio: 4/3; overflow: hidden; background: var(--surface-2); }
.rcard-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, opacity .35s ease; }
/* Khung chờ khi chưa có ảnh */
.ph { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; text-align: center; font-family: var(--serif); font-weight: 600; font-style: italic; line-height: 1.25; color: var(--muted); background: var(--surface-2); }
.ph span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
/* Ảnh hiện dần khi tải xong */
.js .rcard-img img, .js .slot-img img, .js .hero-img, .js .step-img { opacity: 0; }
.js .rcard-img img.ok, .js .slot-img img.ok, .js .hero-img.ok, .js .step-img.ok { opacity: 1; }
.hero-img, .step-img { transition: opacity .35s ease; background: var(--surface-2); }
.badge-video { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge-video .ic { width: 14px; height: 14px; }
.badge-video { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .72); color: #fff; }
.rcard-body { padding: 10px 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rcard-meta { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.rcard-meta span { display: inline-flex; align-items: center; gap: 4px; }
.rcard-meta .ic { width: 15px; height: 15px; }
.rcard-meta b { font-weight: 600; color: var(--k, var(--muted)); }
.rcard-cat { color: var(--muted); font-weight: 500; font-size: 13px; }
.rcard-body strong { font-family: var(--serif); font-size: 1.05em; line-height: 1.3; }
.meta { display: inline-flex; align-items: center; gap: 4px; font-size: .82em; color: var(--muted); }
.meta .ic { width: 15px; height: 15px; }
.filters { display: grid; gap: 2px; margin: 8px 0; }
.sort { display: flex; align-items: center; gap: 10px; max-width: 320px; }
.sort span { font-size: .85em; color: var(--muted); white-space: nowrap; }

/* Trang công thức */
.media { margin: 14px 0; }
.media figcaption { font-size: .85em; color: var(--muted); margin-top: 6px; }
.credit, .media .credit { font-size: 13px; line-height: 1.4; color: var(--muted); margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credit a { color: inherit; }
.hero-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); display: block; }
.player-box { aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: #000; }
.player-box.vertical { aspect-ratio: 9/16; max-width: 240px; margin: 0 auto; }
.player-box iframe, .vcard-media iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 799px) { .media.sticky { position: sticky; top: 61px; z-index: 15; margin: 0 -18px; } .media.sticky .player-box:not(.vertical) { border-radius: 0; } .media.sticky figcaption, .media.sticky .seg { display: none; } .media.sticky .player-box.vertical { max-width: 200px; } }
.lite-yt { position: relative; display: block; width: 100%; height: 100%; border: 0; padding: 0; background: #000; cursor: pointer; }
.lite-yt img { width: 100%; height: 100%; object-fit: cover; }
.lite-yt .play { position: absolute; inset: 0; margin: auto; width: 68px; height: 48px; border-radius: 14px; background: var(--accent); }
.lite-yt .play::after { content: ""; position: absolute; left: 27px; top: 14px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.cook-nav .btn { min-height: 60px; font-size: 1.1em; }

/* Hẹn giờ */
.timer-chip { position: fixed; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.timer { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--bg); padding: 8px 8px 8px 14px; border-radius: 16px; box-shadow: var(--shadow); font-weight: 600; }
.timer b { font-variant-numeric: tabular-nums; font-size: 1.15em; }
.timer button { border: 0; background: rgba(255,255,255,.15); color: inherit; border-radius: 10px; min-width: 36px; height: 36px; cursor: pointer; }
.timer.ring { background: var(--primary); color: var(--primary-ink); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }

/* Đi chợ */
.shop-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.shop-list li + li { border-top: 1px solid var(--line); }
.shop-list label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; }
.shop-list input { width: 22px; height: 22px; accent-color: var(--herb); margin-top: 3px; flex: none; }
.shop-list label:has(input:checked) span { text-decoration: line-through; color: var(--muted); }
.shop-list small { display: block; color: var(--muted); }
.shop-recipes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.shop-recipes .chip { padding-right: 4px; }
.shop-recipes .chip a { display: inline-flex; align-items: center; min-height: 44px; }
.shop-recipes .chip button { border: 0; background: none; cursor: pointer; font-size: 18px; min-width: 44px; min-height: 44px; padding: 0; color: var(--muted); }

.empty { text-align: center; padding: 32px 18px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); margin: 18px 0; }
/* Video */
.rcard-img:has(.badge-video)::after { content: ""; position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, .58) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='%23fff'/%3E%3C/svg%3E") center / 28px no-repeat; box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); pointer-events: none; }
.vstrip { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 18px 12px; margin: 0 -18px; scrollbar-width: none; }
.vcard { flex: none; width: 190px; scroll-snap-align: center; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.vcard:not(.doc) { width: 290px; }
.vcard-media { aspect-ratio: 16/9; background: #000; }
.vcard.doc .vcard-media { aspect-ratio: 9/16; }
.vcard.playing { border-color: var(--accent); }
.vcard-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 6px; flex: 1; }
.vcard-body strong { font-family: var(--serif); line-height: 1.3; }
.vcard-body small { color: var(--muted); font-size: 13px; }
.vcard-body p { margin: 2px 0; color: var(--muted); font-size: .88em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.vcard-link { margin-top: auto; display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
.vstage { margin: 8px 0 28px; }
.vstage .player-box.vertical { max-width: min(360px, calc(50vh * 9 / 16)); }
.vstage h2 { margin: 2px 0 4px; }
.vnav { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; margin: 12px 0 8px; }
.vnav .btn { justify-content: center; padding: 0 12px; white-space: nowrap; }
.empty-title { font-weight: 600; color: var(--text); }
.prose { max-width: 720px; }
.prose h2 { margin-top: 1.5em; }
.ad-slot { min-height: 280px; margin: 28px 0; padding-top: 16px; text-align: center; border-top: 1px solid var(--line); }
.ad-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.footer { margin-top: 56px; padding-top: 18px; padding-bottom: 24px; border-top: 1px solid var(--line); font-size: .85em; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 18px; margin: 4px 0; }
.by { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); }
.yendan { display: inline-flex; align-items: center; gap: 6px; font: 700 1.2em var(--serif); color: var(--text); }
.yendan svg { width: 24px; height: 24px; color: var(--primary); }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 90; font-size: .9em; max-width: 90vw; }

@media print {
  .topbar, .tabbar, .footer, .actions, .media, .ad-slot, .crumbs, .step-tools, .stepper, .serv-quick, .ing-box .row { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
