:root {
  --red: #c60012;
  --red-2: #e10016;
  --red-dark: #9e000d;
  --red-soft: #fff0f1;
  --orange: #f35a22;
  --text: #17191d;
  --muted: #5e636b;
  --line: #e7e7e7;
  --page-max: 480px;
  --pad-x: clamp(12px, 3.8vw, 18px);
  --nav-h: 70px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
html { background: #ededed; }
body {
  min-width: 320px;
  overflow: hidden;
  color: var(--text);
  background: #f4f4f4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app {
  width: min(100%, var(--page-max));
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: #fff;
  box-shadow: 0 0 28px rgba(0,0,0,.08);
}
.fixed-zone { min-width: 0; }

/* ===== Header đỏ cố định ===== */
.hero {
  position: relative;
  min-height: 154px;
  padding: max(16px, env(safe-area-inset-top)) 54px 30px 18px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  background: linear-gradient(135deg, #c40010 0%, #b6000e 48%, #d90013 100%);
  color: #fff;
}
.hero-art {
  position: absolute;
  border: 22px solid rgba(255,255,255,.07);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  transform: rotate(14deg);
  pointer-events: none;
}
.hero-art-1 { width: 235px; height: 235px; right: -76px; top: -90px; }
.hero-art-2 { width: 180px; height: 180px; right: -26px; top: 16px; border-width: 16px; opacity: .7; }

.profile {
  position: relative;
  z-index: 2;
  width: 86px;
  height: 86px;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(86,0,7,.2);
}
.hero-copy { position: relative; z-index: 2; min-width: 0; padding-top: 6px; }
.hero-copy h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(20px, 5.2vw, 28px);
  line-height: 1.08;
  font-weight: 800;
}
.hero-copy > p { margin: 7px 0 12px; font-size: clamp(14px, 4vw, 18px); }
.hero-copy > p span { margin: 0 6px; }

.date-picker {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  cursor: pointer;
}
.date-picker svg {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.date-picker span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(13px, 3.7vw, 17px);
}
.date-picker input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  opacity: .001;
  cursor: pointer;
  color-scheme: light;
}

.bell-btn {
  position: absolute;
  z-index: 3;
  top: max(19px, env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 48px;
  padding: 5px;
  border: 0;
  background: transparent;
  color: #fff;
}
.bell-btn svg { width: 100%; height: 100%; fill: currentColor; stroke: currentColor; stroke-width: 1.3; }
.notification-badge, .card-badge {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ff3342;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 0 2px rgba(255,255,255,.55);
}
.notification-badge { width: 26px; height: 26px; right: -3px; top: -1px; font-size: 14px; }

/* ===== Bữa ăn hôm nay cố định ===== */
.today-card {
  position: relative;
  z-index: 4;
  margin: -18px 12px 0;
  padding: 13px 14px 12px;
  border: 1px solid #e7e7e7;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.today-title-row { display: flex; align-items: center; gap: 10px; }
.meal-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-size: 22px;
}
.today-title-row h2 { margin: 0; font-size: clamp(20px, 5vw, 25px); line-height: 1.1; }
.today-meta-row {
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.today-meta { min-width: 0; display: grid; gap: 5px; }
.meta-line { display: flex; align-items: center; gap: 7px; font-size: clamp(13px, 3.5vw, 16px); white-space: nowrap; }
.meta-line i { font-style: normal; color: #6d7278; }
.meta-icon { width: 18px; color: var(--red); text-align: center; font-size: 17px; }
.status-pill {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 15px;
  background: #fff0e9;
  color: var(--orange);
  font-size: clamp(11px, 3vw, 14px);
  font-weight: 700;
  white-space: nowrap;
}

/* Không có ảnh món ăn: chỉ tên món dạng chip chữ */
.dish-text-grid {
  margin: 11px 0 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.dish-text-grid span {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid #f0d3d6;
  border-radius: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff8f8;
  color: #333;
  text-align: center;
  font-size: clamp(11px, 3vw, 14px);
}
.menu-btn {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--red-2);
  border-radius: 10px;
  background: #fff;
  color: var(--red);
  font-size: clamp(15px, 4vw, 19px);
  font-weight: 800;
}
.menu-btn:active { background: #fff4f5; }

/* ===== CHỈ VÙNG NÀY CUỘN ===== */
.utility-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  padding: 14px var(--pad-x) 16px;
  background: #fff;
}
.utility-scroll::-webkit-scrollbar { width: 0; height: 0; }
.utility-heading { margin: 0 0 10px; font-size: clamp(19px, 5vw, 24px); line-height: 1.15; }
.utility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.utility-card {
  position: relative;
  min-width: 0;
  min-height: 104px;
  padding: 10px;
  border: 1px solid #e7e7e7;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 58px minmax(0,1fr);
  gap: 9px;
  align-items: center;
  background: #fff;
  color: var(--text);
  text-align: left;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.utility-card:active { transform: translateY(1px); background: #fffafa; }
.utility-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff4f5, #ffe8ea);
  color: var(--red);
}
.utility-icon svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.utility-icon .fill-dot { fill: currentColor; stroke: none; }
.utility-copy { min-width: 0; display: grid; gap: 3px; }
.utility-copy strong { font-size: clamp(13px, 3.6vw, 17px); line-height: 1.1; }
.utility-copy small { color: #41464d; font-size: clamp(11px, 3.1vw, 14px); line-height: 1.25; }
.utility-copy em {
  justify-self: start;
  margin-top: 2px;
  padding: 3px 6px;
  border: 1px solid #ffc9ad;
  border-radius: 999px;
  background: #fff3ea;
  color: #f06a2c;
  font-size: clamp(10px, 2.8vw, 12px);
  font-style: normal;
  white-space: nowrap;
}
.card-badge { width: 26px; height: 26px; right: 9px; top: 8px; font-size: 13px; }

.preference-note {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid #ffb6bc;
  border-radius: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fff7f8;
  color: var(--red-dark);
}
.note-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 800;
}
.preference-note p { margin: 0; font-size: clamp(12px, 3.4vw, 15px); line-height: 1.35; }

/* ===== Bottom nav cố định ===== */
.bottom-nav {
  min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 8px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid #e7e7e7;
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  align-items: center;
  background: #fff;
  box-shadow: 0 -4px 14px rgba(0,0,0,.04);
}
.bottom-nav button {
  position: relative;
  height: 54px;
  border: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  background: transparent;
  color: #5b6066;
}
.bottom-nav button span { font-size: 26px; line-height: 1; }
.bottom-nav button small { font-size: 11px; font-weight: 700; }
.bottom-nav button.active { color: var(--red); }
.bottom-nav button.active::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -6px;
  height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--red);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(88vw, 420px);
  padding: 9px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  background: #301214;
  color: #fff;
  text-align: center;
  font-size: 13px;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Mobile hẹp */
@media (max-width: 380px) {
  .hero { grid-template-columns: 74px minmax(0,1fr); min-height: 142px; padding-left: 14px; padding-right: 48px; }
  .profile { width: 74px; height: 74px; }
  .hero-copy h1 { font-size: 19px; }
  .today-card { margin-left: 9px; margin-right: 9px; padding-left: 11px; padding-right: 11px; }
  .today-title-row h2 { font-size: 19px; }
  .meal-icon { width: 38px; height: 38px; }
  .utility-grid { gap: 8px; }
  .utility-card { min-height: 96px; grid-template-columns: 50px minmax(0,1fr); padding: 8px; }
  .utility-icon { width: 50px; height: 50px; }
  .utility-icon svg { width: 35px; height: 35px; }
}

/* Màn hình thấp: co phần FIX, phần tiện ích vẫn là vùng cuộn */
@media (max-height: 760px) {
  :root { --nav-h: 61px; }
  .hero { min-height: 132px; padding-top: max(11px, env(safe-area-inset-top)); padding-bottom: 24px; }
  .profile { width: 70px; height: 70px; }
  .hero { grid-template-columns: 70px minmax(0,1fr); }
  .hero-copy { padding-top: 2px; }
  .hero-copy > p { margin: 5px 0 7px; }
  .date-picker { min-height: 29px; }
  .today-card { margin-top: -15px; padding-top: 10px; padding-bottom: 9px; }
  .today-title-row h2 { font-size: 19px; }
  .meal-icon { width: 36px; height: 36px; font-size: 19px; }
  .today-meta-row { margin-top: 6px; }
  .dish-text-grid { margin: 7px 0; }
  .dish-text-grid span { padding-top: 6px; padding-bottom: 6px; }
  .menu-btn { min-height: 35px; }
  .utility-scroll { padding-top: 10px; }
  .bottom-nav { padding-top: 3px; }
  .bottom-nav button { height: 47px; }
}

@media (max-height: 640px) {
  .hero { min-height: 118px; padding-bottom: 20px; }
  .profile { width: 58px; height: 58px; }
  .hero { grid-template-columns: 58px minmax(0,1fr); gap: 10px; }
  .hero-copy h1 { font-size: 17px; }
  .hero-copy > p { font-size: 13px; margin: 4px 0 5px; }
  .date-picker span { font-size: 12px; }
  .date-picker svg { width: 19px; height: 19px; }
  .today-card { padding: 8px 10px; border-radius: 14px; }
  .today-title-row h2 { font-size: 17px; }
  .meal-icon { width: 32px; height: 32px; }
  .meta-line { font-size: 11.5px; gap: 4px; }
  .status-pill { padding: 6px 8px; font-size: 10.5px; }
  .dish-text-grid { margin: 5px 0; gap: 4px; }
  .dish-text-grid span { padding: 5px 3px; font-size: 10px; }
  .menu-btn { min-height: 31px; font-size: 14px; }
  .utility-scroll { padding-top: 8px; }
}

/* Desktop chỉ để preview; thiết kế vẫn dành riêng cho mobile */
@media (min-width: 481px) {
  body { padding: 0 12px; }
}
