/* Cơm Nhà – sứ men lam (trắng xanh, viền cobalt) trên nền men, mâm gỗ cho phần đã chọn. */

:root {
  color-scheme: light;
  --bg: #EDF1F6;
  --bg-deep: #E2E8F1;
  --surface: #F8FAFC;
  --line: #CBD5E6;
  --ink: #18223A;
  --ink-2: #4B5776;
  --ink-3: #6F7A96;
  --cobalt: #1F3F8F;
  --cobalt-2: #2B51AE;
  --cobalt-ink: #FFFFFF;
  --cobalt-soft: #C3D0EB;
  --cobalt-mist: #DCE4F3;
  --caramel: #B05F17;
  --caramel-ink: #FFFFFF;
  --caramel-soft: #F6E4CF;
  --chili: #C23A2B;
  --chili-soft: #F8DCD7;
  --wood-1: #A9744A;
  --wood-2: #93613A;
  --wood-3: #6E4426;
  --shadow: 24 36 72;
  --disc-fill: #F5F8FC;
  --disc-line: #1F3F8F;
  --disc-soft: #CCD8EF;

  /* Đĩa sứ giữ màu thật ở cả hai chế độ */
  --porcelain: #F7F9FC;
  --rim: #1F3F8F;
  --rim-soft: #9FB3DD;
  --paper: #FFFEFA;
  --paper-ink: #1B2235;

  --font-display: "Phudu", "Be Vietnam Pro", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tray-w: 392px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.5, .64, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1630;
    --bg-deep: #0A1127;
    --surface: #16213F;
    --line: #2A3A66;
    --ink: #E6EBF7;
    --ink-2: #AEB9D4;
    --ink-3: #8390B2;
    --cobalt: #9DB5F3;
    --cobalt-2: #B6C9F7;
    --cobalt-ink: #0E1630;
    --cobalt-soft: #33477C;
    --cobalt-mist: #1F2D55;
    --caramel: #EBA662;
    --caramel-ink: #1C1206;
    --caramel-soft: #3B2B1C;
    --chili: #F28B79;
    --chili-soft: #45242A;
    --wood-1: #8C5F39;
    --wood-2: #7A5030;
    --wood-3: #4F311A;
    --shadow: 0 0 0;
    --disc-fill: #15203E;
    --disc-line: #6680C6;
    --disc-soft: #1F2E58;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1630;
  --bg-deep: #0A1127;
  --surface: #16213F;
  --line: #2A3A66;
  --ink: #E6EBF7;
  --ink-2: #AEB9D4;
  --ink-3: #8390B2;
  --cobalt: #9DB5F3;
  --cobalt-2: #B6C9F7;
  --cobalt-ink: #0E1630;
  --cobalt-soft: #33477C;
  --cobalt-mist: #1F2D55;
  --caramel: #EBA662;
  --caramel-ink: #1C1206;
  --caramel-soft: #3B2B1C;
  --chili: #F28B79;
  --chili-soft: #45242A;
  --wood-1: #8C5F39;
  --wood-2: #7A5030;
  --wood-3: #4F311A;
  --shadow: 0 0 0;
  --disc-fill: #15203E;
  --disc-line: #6680C6;
  --disc-soft: #1F2E58;
}

/* ---------- Nền tảng ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }

.ic {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Nút ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s var(--ease-out), background-color .2s, color .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-sm .ic { width: 18px; height: 18px; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--cobalt);
  color: var(--cobalt-ink);
  box-shadow: 0 10px 22px -12px rgb(var(--shadow) / .8);
}
@media (hover: hover) { .btn-primary:hover:not(:disabled) { background: var(--cobalt-2); } }

.btn-soft { background: var(--cobalt-mist); color: var(--cobalt); }
@media (hover: hover) { .btn-soft:hover { background: var(--cobalt-soft); } }

.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
@media (hover: hover) { .btn-ghost:hover { background: var(--surface); color: var(--ink); } }

.btn-warn { background: transparent; color: var(--chili); border-color: var(--line); }
.is-armed { background: var(--chili); border-color: var(--chili); color: #fff; }
@media (hover: hover) { .btn-warn:hover { background: var(--chili); border-color: var(--chili); color: #fff; } }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
@media (hover: hover) { .icon-btn:hover { background: var(--surface); color: var(--ink); } }

/* Ô tăng giảm số phần */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.step-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--cobalt-mist);
  color: var(--cobalt);
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .15s;
}
@media (hover: hover) { .step-btn:hover { background: var(--cobalt); color: var(--cobalt-ink); } }
.step-btn:active { transform: scale(.9); }
.step-btn:disabled { opacity: .4; cursor: not-allowed; background: var(--cobalt-mist); color: var(--cobalt); }
.step-val {
  min-width: 76px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-val small { font-size: 14px; font-weight: 400; color: var(--ink-2); }
.stepper-sm .step-btn { width: 32px; height: 32px; }
.stepper-sm .step-btn .ic { width: 16px; height: 16px; }
.stepper-sm .step-val { min-width: 30px; font-size: 15px; }

/* ---------- Khung trang ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--tray-w);
  min-height: 100vh;
  min-height: 100dvh;
}

.main-col { min-width: 0; padding: 14px 32px 40px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cobalt);
  text-decoration: none;
}
.brand-mark { width: 34px; height: 34px; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 25px;
  letter-spacing: .01em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Chọn ngày (lịch bloc) và bữa ---------- */

.when {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 8px;
}

.days {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 10px;
  padding: 8px 4px 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.days::-webkit-scrollbar { display: none; }

.day {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 68px;
  padding: 0 0 6px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line), 0 6px 14px -10px rgb(var(--shadow) / .55);
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform .3s var(--ease-spring), box-shadow .25s;
}
@media (hover: hover) { .day:hover { transform: translateY(-2px); } }
.day-top {
  align-self: stretch;
  padding: 3px 0 2px;
  background: var(--cobalt-mist);
  color: var(--cobalt);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.day-num {
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 29px;
  line-height: 1;
  color: var(--ink);
}
.day-mon { font-size: 11px; color: var(--ink-3); }
.day-marks { display: flex; gap: 6px; margin-top: 4px; }
.day-marks .ic { width: 14px; height: 14px; stroke-width: 2.2; color: var(--line); }
.day-marks .is-on { color: var(--caramel); }
.day-marks .is-draft { color: var(--cobalt); }

.day.is-sun .day-top { background: var(--chili-soft); color: var(--chili); }
.day.is-sun .day-num { color: var(--chili); }
.day.is-sel {
  transform: translateY(-4px);
  box-shadow: 0 0 0 2px var(--cobalt), 0 14px 24px -14px rgb(var(--shadow) / .8);
}
.day.is-sel .day-top { background: var(--cobalt); color: var(--cobalt-ink); }
.day.is-sel.is-sun { box-shadow: 0 0 0 2px var(--chili), 0 14px 24px -14px rgb(var(--shadow) / .8); }
.day.is-sel.is-sun .day-top { background: var(--chili); color: #fff; }

.meals {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 300px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.meal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background-color .25s, color .25s;
}
@media (hover: hover) { .meal:hover:not(.is-sel) { background: var(--cobalt-mist); } }
.meal .ic { width: 26px; height: 26px; color: var(--caramel); }
.meal-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.1;
}
.meal-state { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.meal.is-sel { background: var(--cobalt); color: var(--cobalt-ink); }
.meal.is-sel .ic, .meal.is-sel .meal-state { color: inherit; }
.meal.is-sel .meal-state { opacity: .85; }

/* ---------- Tiêu đề ---------- */

.intro { margin-top: 10px; }
#headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 3.8vw, 52px);
  line-height: 1;
  letter-spacing: -.005em;
  color: var(--cobalt);
  text-wrap: balance;
}
.lede { margin-top: 6px; max-width: 56ch; color: var(--ink-2); font-size: 15px; }
.lede-short { display: none; }

/* ---------- Nhóm món + cách xem ---------- */

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.cats {
  position: relative;
  display: inline-flex;
  gap: 2px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat-ink {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--w, 0);
  transform: translateX(var(--x, 0));
  border-radius: 999px;
  background: var(--cobalt);
  transition: transform .5s var(--ease-spring), width .5s var(--ease-spring);
}
.cat {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color .3s;
}
@media (hover: hover) { .cat:hover { color: var(--ink); } }
.cat-n { font-size: 12px; font-weight: 500; color: var(--ink-3); transition: color .3s; }
.cat[aria-pressed="true"], .cat[aria-pressed="true"] .cat-n { color: var(--cobalt-ink); }

.view-switch {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.view-switch button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.view-switch .ic { width: 18px; height: 18px; }
.view-switch button[aria-pressed="true"] { background: var(--cobalt-mist); color: var(--cobalt); }

/* ---------- Mâm xoay ---------- */

.stage {
  --plate: 300px;
  --cy: 220px;
  position: relative;
  height: clamp(290px, calc(100dvh - 500px), 440px);
  margin-top: 4px;
  overflow: hidden;
  border-radius: 28px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 36px), transparent);
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.stage:focus { outline: none; }
.stage:focus-visible { box-shadow: inset 0 0 0 3px var(--cobalt); }
.stage.is-dragging { cursor: grabbing; }

.turntable,
.turntable-shadow {
  position: absolute;
  left: 50%;
  top: calc(var(--cy) + var(--plate) * .03);
  width: calc(var(--plate) * 2.9);
  pointer-events: none;
}
.turntable {
  aspect-ratio: 1;
  transform: translate(-50%, -50%) perspective(1400px) rotateX(71deg);
}
.turntable-shadow {
  height: calc(var(--plate) * 1.1);
  transform: translate(-50%, -44%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(var(--shadow) / .2), transparent);
}
.disc { display: block; width: 100%; height: 100%; overflow: visible; will-change: transform; }
.d-fill { fill: var(--disc-fill); }
.d-line { fill: none; stroke: var(--disc-line); }
.d-soft { fill: none; stroke: var(--disc-line); opacity: .4; }
.d-petal { fill: var(--disc-soft); stroke: var(--disc-line); stroke-width: 2.5; }
.d-dot { fill: var(--disc-line); }

.ring { position: absolute; inset: 0; }

.plate {
  position: absolute;
  left: 50%;
  top: var(--cy);
  width: var(--plate);
  height: var(--plate);
  margin: calc(var(--plate) / -2) 0 0 calc(var(--plate) / -2);
  cursor: pointer;
  will-change: transform, opacity;
}
.plate-body {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 7.5%;
  border-radius: 50%;
  background: var(--porcelain);
  box-shadow:
    inset 0 0 0 calc(var(--plate) * .012) var(--rim),
    inset 0 0 0 calc(var(--plate) * .028) var(--porcelain),
    inset 0 0 0 calc(var(--plate) * .034) var(--rim),
    0 calc(var(--plate) * .07) calc(var(--plate) * .1) calc(var(--plate) * -.04) rgb(var(--shadow) / .5),
    0 2px 4px rgb(var(--shadow) / .18);
  transition: transform .35s var(--ease-out);
}
.plate-body img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 calc(var(--plate) * .006) var(--rim-soft);
  pointer-events: none;
}
.plate-body::after {
  content: "";
  position: absolute;
  inset: 7.5%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgb(255 255 255 / .2), transparent 40%),
    radial-gradient(circle, transparent 64%, rgb(0 0 0 / .24));
  pointer-events: none;
}
.plate-shade {
  position: absolute;
  inset: 7.5%;
  border-radius: 50%;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
}
@media (hover: hover) { .plate.is-front:hover .plate-body { transform: translateY(-6px); } }

/* Dấu phóng to hiện khi rê chuột vào đĩa giữa: bấm đĩa là xem chi tiết */
.plate-hint {
  position: absolute;
  left: 50%;
  bottom: 2%;
  display: grid;
  place-items: center;
  width: calc(var(--plate) * .2);
  height: calc(var(--plate) * .2);
  border-radius: 50%;
  background: var(--cobalt);
  color: var(--cobalt-ink);
  box-shadow: 0 0 0 calc(var(--plate) * .014) var(--porcelain), 0 8px 16px -8px rgb(var(--shadow) / .8);
  opacity: 0;
  transform: translate(-50%, 30%) scale(.5);
  transition: opacity .2s, transform .3s var(--ease-spring);
  pointer-events: none;
}
.plate-hint .ic { width: 55%; height: 55%; stroke-width: 2.4; }
@media (hover: hover) {
  .plate.is-front:hover .plate-hint { opacity: 1; transform: translate(-50%, 0) scale(1); }
  .stage.is-dragging .plate-hint { opacity: 0; }
}

.plate-qty {
  position: absolute;
  top: 4%;
  right: 4%;
  display: grid;
  place-items: center;
  min-width: calc(var(--plate) * .17);
  height: calc(var(--plate) * .17);
  padding: 0 6px;
  border-radius: 999px;
  background: var(--caramel);
  color: var(--caramel-ink);
  box-shadow: 0 0 0 calc(var(--plate) * .014) var(--porcelain);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(var(--plate) * .085);
  line-height: 1;
}
.is-pop { animation: pop .45s var(--ease-spring); }
@keyframes pop {
  from { transform: scale(.3); }
  to { transform: scale(1); }
}

.nav {
  position: absolute;
  top: var(--cy);
  z-index: 200;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--cobalt);
  cursor: pointer;
  transition: background-color .2s, transform .15s;
}
@media (hover: hover) { .nav:hover { background: var(--surface); } }
.nav:active { transform: scale(.92); }
.nav-prev { left: 10px; }
.nav-next { right: 10px; }

/* Thông tin món ở giữa */
.dish-info { text-align: center; }
.dish-text { min-height: 74px; }
.dish-name {
  font-weight: 700;
  font-size: clamp(24px, 2.4vw, 31px);
  line-height: 1.15;
  letter-spacing: -.015em;
  text-wrap: balance;
}
.dish-desc { max-width: 62ch; margin: 6px auto 0; color: var(--ink-2); font-size: 15px; }

.opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#dish-opts .opts { margin-top: 12px; }
.opt {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}
.opt[aria-checked="true"] {
  border-color: var(--cobalt);
  background: var(--cobalt-mist);
  color: var(--cobalt);
  font-weight: 600;
}

.dish-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  min-height: 52px;
  margin-top: 14px;
}
.act-note { font-size: 14px; color: var(--ink-3); }
.pager { margin-top: 10px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Xem dạng danh sách ---------- */

.list-view { margin-top: 16px; }
.lv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lv-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 10px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}
.lv-item.is-in { box-shadow: 0 0 0 2px var(--caramel); }
.lv-thumb {
  --plate: 76px;
  position: relative;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.lv-thumb .plate-body { padding: 8%; }
.lv-text h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }
.lv-name { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .lv-name:hover { color: var(--cobalt); } }
.lv-text p { margin-top: 2px; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.lv-text .opts { justify-content: flex-start; margin-top: 8px; }
.lv-text .opt { padding: 3px 10px; font-size: 13px; }
.add-round {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--cobalt);
  color: var(--cobalt-ink);
  cursor: pointer;
  transition: transform .15s, background-color .2s;
}
@media (hover: hover) { .add-round:hover { background: var(--cobalt-2); } }
.add-round:active { transform: scale(.9); }

/* ---------- Mâm của bạn ---------- */

.tray {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  height: 100dvh;
  padding: 20px 24px 24px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--bg-deep);
  overscroll-behavior: contain;
}
.sheet-handle { display: none; }
.tray-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tray-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 30px;
  line-height: 1.05;
  color: var(--cobalt);
}
.tray-sub { margin-top: 2px; font-size: 14px; color: var(--ink-2); }
.tray-close { display: none; }

.tray-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--caramel-soft);
  font-size: 14px;
}
.tray-status .ic { width: 18px; height: 18px; color: var(--caramel); }
.tray-status.is-dirty { background: var(--cobalt-mist); }
.tray-status.is-dirty .ic { color: var(--cobalt); }
.tray-status.is-warn { align-items: flex-start; background: var(--chili-soft); }
.tray-status.is-warn .ic { margin-top: 2px; color: var(--chili); }

/* Mâm gỗ */
.mam {
  position: relative;
  flex: none;
  width: min(100%, 300px);
  aspect-ratio: 1;
  margin: 2px auto 4px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgb(255 255 255 / .18), transparent 46%),
    repeating-radial-gradient(circle at 47% 44%, var(--wood-1) 0 7px, var(--wood-2) 8px 9px, var(--wood-1) 10px 17px);
  box-shadow:
    inset 0 0 0 10px var(--wood-2),
    inset 0 0 0 12px rgb(0 0 0 / .14),
    inset 0 8px 18px 10px rgb(0 0 0 / .22),
    0 18px 30px -16px rgb(var(--shadow) / .75);
}
.mam.is-bump { animation: bump .45s var(--ease-spring); }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.mp {
  --plate: 80px;
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  width: calc(var(--s) * 100%);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  transform: translate(-50%, -50%);
  transition: left .55s var(--ease-spring), top .55s var(--ease-spring), width .55s var(--ease-spring), opacity .3s;
}
.mp .plate-body {
  padding: 9%;
  box-shadow:
    inset 0 0 0 2px var(--rim),
    inset 0 0 0 4px var(--porcelain),
    inset 0 0 0 5px var(--rim),
    0 8px 12px -6px rgb(30 15 0 / .6);
}
.mp .plate-body::after { inset: 9%; }
.mp-qty {
  position: absolute;
  top: -6%;
  right: -6%;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--caramel);
  color: var(--caramel-ink);
  box-shadow: 0 0 0 2px var(--porcelain);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
}
.mp.is-empty {
  display: grid;
  place-items: center;
  padding: 8%;
  border: 2px dashed rgb(255 246 230 / .7);
  border-radius: 50%;
  background: rgb(255 255 255 / .08);
  color: #FFF6E8;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}
@media (hover: hover) { .mp.is-empty:hover { background: rgb(255 255 255 / .18); } }
.mp.is-incoming { opacity: 0; }
.mp.is-land { animation: land .5s var(--ease-spring); }
.mp.is-leaving { animation: leave .3s ease-in forwards; }
@keyframes land {
  from { transform: translate(-50%, -50%) scale(.55); }
  to { transform: translate(-50%, -50%) scale(1); }
}
@keyframes leave {
  to { transform: translate(-50%, -50%) scale(.2); opacity: 0; }
}

.mam-rice {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: calc(var(--rs, .3) * 100%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 35%, rgb(255 255 255 / .9), transparent 55%),
    radial-gradient(#fff 0 1.2px, transparent 1.6px) 0 0 / 6px 5px,
    radial-gradient(#fff 0 1.2px, transparent 1.6px) 3px 2.5px / 6px 5px,
    #ECEAE2;
  box-shadow:
    0 0 0 5px var(--porcelain),
    0 0 0 6.5px var(--rim),
    0 10px 14px -6px rgb(30 15 0 / .65);
  transition: width .5s var(--ease-spring), opacity .3s;
}
.mam-rice.is-none { opacity: .45; }
.mam-rice-n {
  position: absolute;
  left: 50%;
  bottom: -14%;
  translate: -50% 0;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--cobalt);
  color: #fff;
  box-shadow: 0 0 0 2px var(--porcelain);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
:root[data-theme="dark"] .mam-rice-n { color: var(--cobalt-ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mam-rice-n { color: var(--cobalt-ink); }
}

/* Danh sách món trong mâm */
.tl { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.tl ul { margin: 0; padding: 0; list-style: none; }
.tl-group h3 { margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.tl-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.tl-item + .tl-item { border-top: 1px solid var(--line); }
.tl-thumb { --plate: 42px; width: 42px; height: 42px; }
.tl-thumb .plate-body { padding: 9%; box-shadow: inset 0 0 0 1.5px var(--rim), 0 3px 6px -3px rgb(var(--shadow) / .6); }
.tl-thumb .plate-body::after { inset: 9%; }
.tl-name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.tl-open {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.tl-empty { font-size: 14px; color: var(--ink-2); }

.tray-fields { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.rice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--surface);
}
.rice-label { font-weight: 600; }
.rice-hint { font-size: 12px; color: var(--ink-3); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px var(--cobalt-mist);
}
.field ::placeholder { color: var(--ink-3); }
.by-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.by-chips:empty { display: none; }
.by-chip {
  min-width: 56px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}
@media (hover: hover) { .by-chip:hover { border-color: var(--cobalt); color: var(--cobalt); } }
.by-chip[aria-pressed="true"] { border-color: var(--cobalt); background: var(--cobalt-mist); color: var(--cobalt); }

.tray-actions {
  position: sticky;
  bottom: -24px;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: auto -24px -24px;
  padding: 12px 24px 24px;
  background: var(--bg-deep);
  box-shadow: 0 -12px 20px -16px rgb(var(--shadow) / .55);
}
.tray-actions > .btn-block { grid-column: 1 / -1; }
.btn-count { font-weight: 400; opacity: .85; }

/* ---------- Thanh mâm dưới đáy (điện thoại) ---------- */

.dock { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(8 14 32 / .45);
  opacity: 0;
  transition: opacity .3s;
}
.scrim.is-on { opacity: 1; }

.dock-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 7px 8px 7px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--cobalt);
  color: var(--cobalt-ink);
  box-shadow: 0 16px 32px -14px rgb(var(--shadow) / .9);
  text-align: left;
  cursor: pointer;
}
.dock-mam {
  display: grid;
  place-items: center;
  flex: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at 47% 44%, var(--wood-1) 0 4px, var(--wood-2) 5px 6px, var(--wood-1) 7px 10px);
  box-shadow: inset 0 0 0 4px var(--wood-2), inset 0 4px 8px 4px rgb(0 0 0 / .2);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  text-shadow: 0 1px 2px rgb(0 0 0 / .4);
}
.dock-mam.is-bump { animation: bump .45s var(--ease-spring); }
.dock-text { display: flex; flex-direction: column; min-width: 0; }
.dock-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-cta {
  flex: none;
  margin-left: auto;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgb(255 255 255 / .16);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Món đang bay vào mâm ---------- */

.flyer {
  --plate: 100px;
  position: fixed;
  z-index: 300;
  pointer-events: none;
  will-change: transform;
}
.flyer .plate-body { box-shadow: inset 0 0 0 3px var(--rim), 0 20px 30px -12px rgb(var(--shadow) / .6); }

/* ---------- Hộp thoại ---------- */

dialog { color: var(--ink); }
dialog::backdrop { background: rgb(8 14 32 / .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

/* Lịch sử: ngăn kéo bên phải */
.hist-dlg {
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: var(--bg);
}
.hist-dlg[open] { animation: drawer-in .42s var(--ease-out); }
@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.hist { display: flex; flex-direction: column; height: 100%; }
.hist-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.hist-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1.05; color: var(--cobalt); }
.hist-mode { margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.hist-body { flex: 1; padding: 8px 24px 32px; overflow-y: auto; }
.hist-sec { padding-top: 18px; }
.hist-sec > h3 { font-weight: 700; font-size: 18px; color: var(--ink); }
.hist-empty { padding: 32px 4px; color: var(--ink-2); text-align: center; }
.hist-backup { margin-top: 8px; }
.hist-backup p { margin-top: 6px; max-width: 52ch; font-size: 14px; color: var(--ink-2); }
.hist-empty .brand-mark { width: 48px; height: 48px; margin: 0 auto 10px; color: var(--cobalt-soft); }

.fav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.fav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  text-align: center;
}
@media (hover: hover) { .fav-btn:hover { background: var(--surface); } }
.fav-plate { --plate: 64px; position: relative; width: 64px; height: 64px; }
.fav-plate .plate-body { padding: 8%; box-shadow: inset 0 0 0 2px var(--rim), 0 6px 10px -6px rgb(var(--shadow) / .7); }
.fav-plate .plate-body::after { inset: 8%; }
.fav-n {
  position: absolute;
  right: -8px;
  top: -4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--caramel);
  color: var(--caramel-ink);
  font-size: 12px;
  font-weight: 700;
}
.fav-name { font-size: 13px; line-height: 1.3; color: var(--ink-2); }

.hl { margin: 6px 0 0; padding: 0; list-style: none; }
.he {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.he-cal {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  padding-bottom: 6px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}
.he-cal-top { align-self: stretch; padding: 2px 0; background: var(--cobalt); color: var(--cobalt-ink); font-size: 11px; font-weight: 600; text-align: center; }
.he-cal-num { margin-top: 4px; font-family: var(--font-display); font-weight: 800; font-size: 24px; line-height: 1; }
.he-cal-mon { font-size: 11px; color: var(--ink-3); }
.he-cal.is-sun .he-cal-top { background: var(--chili); color: #fff; }
.he-cal.is-sun .he-cal-num { color: var(--chili); }
.he-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.he-title .ic { width: 18px; height: 18px; color: var(--caramel); }
.he-badge { padding: 1px 8px; border-radius: 999px; background: var(--chili-soft); color: var(--chili); font-size: 12px; font-weight: 600; }
.he-badge.is-ok { background: var(--caramel-soft); color: var(--caramel); }
.he-plates { display: flex; margin-top: 8px; padding-left: 8px; }
.he-plate { --plate: 40px; width: 40px; height: 40px; margin-left: -8px; }
.he-plate .plate-body { padding: 7%; box-shadow: inset 0 0 0 1.5px var(--rim), 0 0 0 2px var(--bg); }
.he-plate .plate-body::after { display: none; }
.he-more {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--cobalt-mist);
  color: var(--cobalt);
  box-shadow: 0 0 0 2px var(--bg);
  font-size: 13px;
  font-weight: 700;
}
.he-dishes { margin-top: 8px; font-size: 14px; line-height: 1.45; }
.he-meta { margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.he-note { margin-top: 4px; font-size: 13px; color: var(--ink-2); font-style: italic; }
.he-act { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.he.is-cancelled .he-plates, .he.is-cancelled .he-dishes { opacity: .5; }
.he.is-cancelled .he-dishes { text-decoration: line-through; }

/* Phiếu gọi món */
.rc-dlg {
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.rc-dlg[open] { display: flex; flex-direction: column; }
.receipt {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  padding: 26px 24px 34px;
  overflow-y: auto;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 15px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 18px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 18px 100%;
}
.receipt.is-printing { animation: print-out 1s var(--ease-out) both; }
@keyframes print-out {
  from { clip-path: inset(0 0 100% 0); transform: translateY(-28px); }
  to { clip-path: inset(0 0 0 0); transform: none; }
}
.rc-head { text-align: center; }
.rc-mark { width: 40px; height: 40px; color: #1F3F8F; }
.rc-head h2 { margin-top: 4px; font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1.05; color: #1F3F8F; }
.rc-brand { font-size: 13px; color: #5A6580; }
.rc-slot { margin-top: 12px; font-weight: 700; font-size: 17px; }
.rc-meta { margin-top: 2px; font-size: 13px; color: #5A6580; }
.rc-body { margin-top: 16px; padding-top: 14px; border-top: 1.5px dashed #C3CBDB; }
.rc-group + .rc-group { margin-top: 12px; }
.rc-group h3 { font-size: 12px; font-weight: 600; color: #6A748D; }
.rc-line { display: grid; grid-template-columns: 34px 1fr; gap: 6px; margin-top: 4px; line-height: 1.35; }
.rc-q { font-weight: 700; color: #1F3F8F; font-variant-numeric: tabular-nums; }
.rc-sum {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1.5px dashed #C3CBDB;
  font-weight: 600;
}
.rc-note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #F2F4F8; font-size: 14px; }
.rc-note b { display: block; font-size: 12px; font-weight: 600; color: #6A748D; }
.rc-cancel {
  margin-top: 14px;
  padding: 6px 10px;
  border: 2px solid #C23A2B;
  border-radius: 8px;
  color: #C23A2B;
  font-weight: 700;
  text-align: center;
  transform: rotate(-3deg);
}

.rc-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 22px;
  background: var(--surface);
}
.rc-hint { font-size: 14px; color: var(--ink-2); text-align: center; }
.rc-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Xem chi tiết món: ảnh đầy đủ ở trên, thông tin bên dưới, nút thêm món ghim ở đáy */
.dish-dlg {
  width: min(780px, calc(100vw - 32px), max(520px, calc((100dvh - 300px) * 1.79)));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / .6);
}
.dish-dlg[open] { display: flex; animation: dd-in .35s var(--ease-out); }
@keyframes dd-in {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.dd {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dd-photo {
  position: relative;
  flex: none;
  margin: 0;
  aspect-ratio: 1280 / 714;
  overflow: hidden;
  background: var(--bg-deep);
  cursor: zoom-in;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.dd-photo img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.dd-photo img.is-loaded { opacity: 1; }
.dd-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / .86);
  color: #18223A;
  box-shadow: 0 6px 16px -8px rgb(0 0 0 / .6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.dd-close { top: 12px; right: 12px; }
.dd-nav { top: 50%; margin-top: -22px; }
.dd-prev { left: 12px; }
.dd-next { right: 12px; }
.dd-pill {
  position: absolute;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: rgb(10 16 35 / .58);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.dd-pill .ic { width: 16px; height: 16px; }
.dd-count { left: 12px; font-variant-numeric: tabular-nums; }
.dd-zoom { right: 12px; cursor: pointer; }
.dd-body { flex: 1 0 auto; padding: 20px 24px 4px; }
#dd-name { font-size: clamp(24px, 3vw, 30px); font-weight: 700; line-height: 1.15; letter-spacing: -.015em; }
#dd-name:focus { outline: none; }
.dd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--cobalt-mist);
  color: var(--cobalt);
  font-size: 13px;
  font-weight: 600;
}
.tag-spicy-1 { background: var(--caramel-soft); color: var(--caramel); }
.tag-spicy-2 { background: var(--chili-soft); color: var(--chili); }
.tag-hist { background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.dd-desc { max-width: 62ch; margin-top: 12px; color: var(--ink-2); font-size: 16px; }
.dd-facts { margin: 14px 0 0; }
.dd-facts > div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.dd-facts dt { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.dd-facts dd { margin: 0; font-size: 15px; }
#dd-opts .opts { justify-content: flex-start; margin-top: 14px; }
.dd-pairs { margin-top: 16px; }
.dd-pairs h3 { font-size: 15px; font-weight: 700; }
.dd-pairs ul { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 0; padding: 0; list-style: none; }
.dd-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) { .dd-pair:hover { border-color: var(--cobalt); color: var(--cobalt); } }
.dd-pair-plate { --plate: 40px; display: block; flex: none; width: 40px; height: 40px; }
.dd-pair-plate .plate-body { padding: 8%; box-shadow: inset 0 0 0 1.5px var(--rim); }
.dd-pair-plate .plate-body::after { display: none; }
.dd-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 16px;
  padding: 12px 24px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 -10px 20px -14px rgb(var(--shadow) / .55);
}
.dd-bar .stepper { animation: dd-pop .35s var(--ease-spring); }
@keyframes dd-pop {
  from { transform: scale(.88); }
  to { transform: scale(1); }
}

/* Ảnh lớn toàn màn hình */
.img-dlg {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  cursor: zoom-out;
}
.img-dlg[open] { display: grid; place-items: center; }
.img-dlg::backdrop { background: #000; }
.img-dlg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-close { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }

/* ---------- Thông báo ngắn ---------- */

.toast {
  position: fixed;
  inset: auto auto auto 50%;
  margin: 0;
  border: 0;
  overflow: visible;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 400;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .25s, transform .35s var(--ease-out);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Laptop màn thấp (1366×768 trừ thanh trình duyệt): gọn để thấy nút thêm món ---------- */

@media (min-width: 1024px) and (max-height: 800px) {
  .main-col { padding-top: 10px; padding-bottom: 24px; }
  .when { margin-top: 2px; }
  .days { padding-top: 6px; padding-bottom: 8px; }
  .day-mon { display: none; }
  .day-num { margin-top: 5px; }
  .intro { margin-top: 2px; }
  #headline { font-size: 40px; }
  .lede { display: none; }
  .cat-row { margin-top: 10px; }
  .stage { height: clamp(240px, calc(100dvh - 380px), 440px); }
  .dish-text { min-height: 62px; }
  .dish-act { margin-top: 8px; }
  .pager { margin-top: 6px; }
  .tray { padding-top: 14px; gap: 10px; }
  .mam { width: min(100%, 260px); }
}

/* ---------- Màn hình hẹp: mâm thành ngăn kéo từ dưới lên ---------- */

@media (max-width: 1023px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main-col { padding: 10px 16px calc(108px + env(safe-area-inset-bottom)); }

  .tray {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 80;
    height: auto;
    max-height: 90dvh;
    padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
    border-left: 0;
    border-radius: 26px 26px 0 0;
    background: var(--bg);
    box-shadow: 0 -24px 48px -24px rgb(var(--shadow) / .6);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .45s var(--ease-out), visibility 0s .45s;
  }
  .tray.is-open { transform: none; visibility: visible; transition: transform .45s var(--ease-out), visibility 0s; }
  .tray.is-dragging { transition: none; }
  .sheet-handle { display: block; flex: none; width: 44px; height: 5px; margin: -4px auto 0; border-radius: 3px; background: var(--line); }
  .tray-close { display: grid; }
  .tray-head { touch-action: none; }
  .tray-actions {
    bottom: calc(-20px - env(safe-area-inset-bottom));
    margin: 0 -20px calc(-20px - env(safe-area-inset-bottom));
    padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg);
    box-shadow: 0 -10px 20px -14px rgb(var(--shadow) / .6);
  }

  .dock {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 60;
    display: block;
  }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.sheet-open { overflow: hidden; }
}

@media (max-width: 720px) {
  .when { flex-direction: column; align-items: stretch; gap: 4px; margin-top: 4px; }
  .days { gap: 8px; margin: 0 -16px; padding: 8px 16px 10px; }
  .day { width: 60px; padding-bottom: 5px; }
  .day-num { margin-top: 4px; font-size: 25px; }
  .meals { width: 100%; }
  .meal { padding: 6px 12px; }
  .intro { margin-top: 12px; }
  #headline { font-size: 32px; }
  .lede { font-size: 14px; }
  .lede-long { display: none; }
  .lede-short { display: inline; }
  .cat-row { margin-top: 12px; }
  .cats { flex: 1; }
  .cat { flex: 1; justify-content: center; padding: 8px 6px; font-size: 14px; }
  /* Điện thoại: chỉ hiện nút để đổi sang cách xem còn lại */
  .view-switch { padding: 0; border: 0; background: none; }
  .view-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .view-switch button { width: 44px; height: 44px; justify-content: center; padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--cobalt); }
  .view-switch button[aria-pressed="true"] { display: none; }
  .stage { height: min(80vw, 330px); margin: 0 -16px; border-radius: 0; }
  .nav { width: 40px; height: 40px; margin-top: -20px; }
  .nav-prev { left: 6px; }
  .nav-next { right: 6px; }
  .dish-text { min-height: 84px; }
  .lv { grid-template-columns: minmax(0, 1fr); }
  .lv-item { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; }
  .lv-thumb { --plate: 64px; width: 64px; height: 64px; }
  .lv-act .stepper { flex-direction: column-reverse; }
  .lv-act .step-val { min-width: 0; }
  .hist-head { padding: 16px 16px 12px; }
  .hist-body { padding: 4px 16px 32px; }
}

@media (max-width: 400px) {
  .cat-n { display: none; }
}

/* Điện thoại: khung chi tiết phủ kín màn hình */
@media (max-width: 600px) {
  .dish-dlg { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .dd { height: 100%; max-height: 100dvh; }
  .dd-body { padding: 16px 16px 4px; }
  .dd-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dd-bar { padding-left: 16px; padding-right: 16px; }
  .dd-bar > .btn { flex: 1; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 22px; }
  #btn-history span { display: none; }
  #btn-history { width: 40px; padding: 0; }
  .meal { padding: 8px 10px; gap: 8px; }
  .meal .ic { width: 22px; height: 22px; }
}

/* ---------- iPad ngang (1024–1199): cột mâm hẹp lại để dải ngày đủ chỗ ---------- */

@media (min-width: 1024px) and (max-width: 1199px) {
  :root { --tray-w: 344px; }
  .main-col { padding-left: 24px; padding-right: 24px; }
  .meals { width: 256px; }
  .meal { gap: 8px; padding: 8px 10px; }
  .tray { padding-left: 20px; padding-right: 20px; }
  .tray-actions { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
}

/* ---------- iPad dọc, máy tính bảng nhỏ (721–1023) ---------- */

@media (min-width: 721px) and (max-width: 1023px) {
  .main-col { padding-left: 28px; padding-right: 28px; }
  .stage { height: clamp(320px, 52vw, 480px); }
  /* Ngăn kéo mâm và thanh mâm không trải hết bề ngang iPad */
  .tray { max-width: 640px; margin-inline: auto; }
  .dock { max-width: 560px; margin-inline: auto; }
}

/* ---------- Điện thoại xoay ngang: màn rất thấp ---------- */

@media (max-width: 1023px) and (max-height: 520px) {
  .day-mon { display: none; }
  .intro { margin-top: 6px; }
  #headline { font-size: 28px; }
  .lede { display: none; }
  .cat-row { margin-top: 8px; }
  .stage { height: 250px; }
  .dish-text { min-height: 0; }
  .tray { max-height: 96dvh; }
}

/* Màn có tai thỏ khi xoay ngang */
@supports (padding: max(0px)) {
  @media (max-width: 1023px) {
    .main-col {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }
    .dock {
      left: max(12px, env(safe-area-inset-left));
      right: max(12px, env(safe-area-inset-right));
    }
  }
}

/* ---------- Cảm ứng: nút đủ lớn cho ngón tay (và cho bé) ---------- */

@media (pointer: coarse) {
  /* Không có chuột: hướng dẫn chỉ nói chuyện vuốt */
  .lede-long { display: none; }
  .lede-short { display: inline; }
  .cat { min-height: 44px; }
  .view-switch button { min-height: 40px; }
  .stepper-sm .step-btn { width: 40px; height: 40px; }
  .opt { padding: 9px 16px; }
  .lv-text .opt { padding: 7px 12px; }
  .btn-sm { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .by-chip { padding: 10px 18px; }
  .add-round { width: 48px; height: 48px; }
}

/* ---------- Giảm chuyển động ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- In phiếu ---------- */

@media print {
  body { background: #fff; }
  body > :not(#rc-dlg) { display: none !important; }
  #rc-dlg { position: static; width: 100%; max-height: none; }
  #rc-dlg::backdrop { display: none; }
  .rc-foot { display: none !important; }
  .receipt { -webkit-mask: none; mask: none; animation: none; overflow: visible; }
}
