/* Chăm Em Bé · xanh pastel, sáng.
   Học cách làm của KHI UI kit (khoảng trống, tách tầng bằng sắc nền thay viền, mỗi màn một nút chính, đủ trạng thái),
   KHÔNG chép dáng của KHI: không serif hẹp, không thẻ tối, không bản tối. Pastel #8EC5E8 là màu chủ đạo, chữ luôn xanh đậm.
   Màu chỉ đi qua biến --c-*. Tiền tố class: ceb- */
:root {
  color-scheme: light;
  --c-bg: #F3F8FC;
  --c-sky: linear-gradient(180deg, #D9EDFA 0px, #E8F4FC 200px, #F3F8FC 380px);
  --c-card: #FFFFFF;
  --c-soft: #E6F3FB;       /* nền khối lồng, rãnh chọn đoạn */
  --c-soft-2: #D3EAF8;     /* ô icon, ô đang chọn nhẹ */
  --c-pastel: #8EC5E8;     /* màu chủ đạo: nút chính, chip đang chọn */
  --c-pastel-2: #7DB9E0;   /* nút chính lúc bấm */
  --c-ink: #123247;        /* chữ chính, chữ trên nền pastel (7.2:1) */
  --c-ink-2: #2B5C7E;      /* chữ phụ (≥5.2:1 trên mọi nền sáng) */
  --c-ink-3: #4A7391;      /* chữ mờ, chỉ dùng trên nền trắng và nền app */
  --c-line: rgba(43, 92, 126, 0.10);
  --c-love: #F6C9D4; --c-love-ink: #5A1F33;   /* hồng nhạt: chỉ cho "Đã mua" và việc đến hạn */
  --c-bad: #9B2C2C; --c-bad-bg: #FBE4E4;
  --c-shadow: 0 8px 24px -10px rgba(43, 92, 126, 0.22);
  --c-shadow-lift: 0 14px 32px -12px rgba(43, 92, 126, 0.30);
  --c-ring: 0 0 0 2px #FFFFFF, 0 0 0 4px #2B5C7E;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 20px;
  --r-sm: 14px;
  --spring: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
}

/* ---------- nền ---------- */
* { box-sizing: border-box; }
html { background: var(--c-bg); overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--c-sky) no-repeat, var(--c-bg); color: var(--c-ink);
  font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.is-locked { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; }
a { color: inherit; }
*:focus { outline: none; }
*:focus-visible { box-shadow: var(--c-ring); border-radius: 12px; }
/* Ô nhập: vòng focus vẽ ở khung .ceb-field (focus-within). iOS coi ô nhập luôn là focus-visible, để vòng chung thì ra viền đúp. */
.ceb-field input:focus-visible, .ceb-field textarea:focus-visible { box-shadow: none; border-radius: 0; }
.ceb-ic { flex: none; display: block; }
.ceb-num { font-variant-numeric: tabular-nums; }

.app { max-width: 520px; margin: 0 auto; padding: calc(var(--safe-t) + 12px) 20px calc(var(--safe-b) + 108px); }
.ceb-boot { padding: 48px 0; text-align: center; color: var(--c-ink-2); }

/* ---------- chữ ---------- */
.ceb-hero, .ceb-hl { margin: 0; font-weight: 800; letter-spacing: -0.02em; color: var(--c-ink); text-wrap: balance; }
.ceb-hero { font-size: 28px; line-height: 34px; }
.ceb-hl { font-size: 21px; line-height: 27px; }
.ceb-lede { margin: 6px 0 0; color: var(--c-ink-2); font-size: 15px; line-height: 22px; text-wrap: pretty; }
.ceb-over { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 14px; line-height: 20px; font-weight: 700; color: var(--c-ink); }
.ceb-over--sec { margin-top: 22px; }
.ceb-label { font-size: 14px; line-height: 18px; font-weight: 600; color: var(--c-ink); }
.ceb-label i { font-style: normal; font-weight: 400; color: var(--c-ink-2); margin-left: 4px; }
.ceb-help { margin: 0; font-size: 13px; line-height: 19px; color: var(--c-ink-2); }
.ceb-help--center { margin-top: 4px; text-align: center; }

/* ---------- đầu trang ---------- */
.ceb-top { display: flex; align-items: center; gap: 10px; height: 44px; }
.ceb-top__name { font-size: 15px; font-weight: 700; }
.ceb-top__date { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--c-ink-2); }
.ceb-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; background: var(--c-pastel); color: #FFFFFF; flex: none; }
.ceb-mark svg { fill: currentColor; stroke: none; }
.ceb-mark--lg { width: 72px; height: 72px; border-radius: 24px; margin-bottom: 12px; }
.ceb-intro { padding: 18px 0 20px; }

.ceb-main { display: grid; gap: 16px; }

/* ---------- nút ---------- */
.ceb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px;
  border-radius: var(--r-sm); font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none; user-select: none;
  transition: transform 150ms var(--spring), background-color 200ms, opacity 150ms;
}
.ceb-btn:active:not(:disabled) { transform: scale(0.97); }
.ceb-btn:disabled { opacity: .5; cursor: progress; }
.ceb-btn--primary { background: var(--c-pastel); color: var(--c-ink); }
.ceb-btn--primary:active:not(:disabled) { background: var(--c-pastel-2); }
.ceb-btn--soft { background: var(--c-soft); color: var(--c-ink); }
.ceb-btn--light { background: var(--c-card); color: var(--c-ink); box-shadow: var(--c-shadow); }
.ceb-btn--love { background: var(--c-love); color: var(--c-love-ink); }
.ceb-btn--danger { background: var(--c-bad-bg); color: var(--c-bad); }
.ceb-btn--lg { height: 54px; padding: 0 26px; font-size: 16px; }
.ceb-btn--sm { height: 40px; padding: 0 16px; font-size: 14px; }
.ceb-btn--xs { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 12px; flex: none; }
.ceb-btn--block { width: 100%; }
.ceb-ibtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.ceb-ibtn--light { background: var(--c-card); color: var(--c-ink); box-shadow: var(--c-shadow); }

.ceb-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 9999px; font-size: 12px; font-weight: 700; }
.ceb-badge--due { background: var(--c-love); color: var(--c-love-ink); }

/* ---------- chip, nhóm chọn đoạn ---------- */
/* Cụm nút kiểu hashtag: xuống dòng để thấy hết, không cuộn ngang (cuộn ngang làm khuất ngăn Định kỳ). */
.ceb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ceb-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 9999px;
  font-size: 14px; font-weight: 600; background: var(--c-card); color: var(--c-ink-2); box-shadow: var(--c-shadow);
  transition: background-color 200ms, color 200ms;
}
.ceb-chip__n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--c-soft); color: var(--c-ink-2); font-size: 12px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.ceb-chip[aria-selected="true"] { background: var(--c-pastel); color: var(--c-ink); }
.ceb-chip[aria-selected="true"] .ceb-chip__n { background: rgba(255, 255, 255, .55); color: var(--c-ink); }

.ceb-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--c-soft); }
.ceb-seg > button { min-width: 0; height: 40px; padding: 0 4px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--c-ink-2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color 200ms, color 200ms; }
.ceb-seg > [aria-checked="true"] { background: var(--c-pastel); color: var(--c-ink); }

/* ---------- thẻ, danh sách ---------- */
.ceb-card { background: var(--c-card); border-radius: var(--r); box-shadow: var(--c-shadow); }
.ceb-card--pad { padding: 16px 16px 6px; }
.ceb-card--due { box-shadow: var(--c-shadow), inset 0 0 0 1.5px var(--c-love); }
.ceb-list { list-style: none; margin: 0; padding: 4px 0; background: var(--c-card); border-radius: var(--r); box-shadow: var(--c-shadow); }
.ceb-list--flat { padding: 0; background: none; box-shadow: none; border-radius: 0; margin: 0 -16px; }
.ceb-sheet .ceb-list--flat { margin: 8px -4px 16px; }
.ceb-list > li { position: relative; }
.ceb-list > li + li::before { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: var(--c-line); }

.ceb-li { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; text-align: left; color: var(--c-ink); text-decoration: none; border-radius: 14px; transition: background-color 200ms; }
button.ceb-li:active, a.ceb-li:active, .ceb-li__main:active { background: var(--c-soft); }
li.ceb-li { padding-left: 0; padding-right: 16px; }
.ceb-card .ceb-list--flat > li.ceb-li { padding-right: 16px; }
.ceb-li__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; align-self: stretch; padding: 12px 0 12px 16px; text-align: left; border-radius: 0 14px 14px 0; }
.ceb-li__ic { width: 40px; height: 40px; border-radius: 13px; background: var(--c-soft-2); color: var(--c-ink-2); display: grid; place-items: center; flex: none; }
.ceb-li__ic--lg { width: 52px; height: 52px; border-radius: 16px; }
.ceb-li__tx { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ceb-li__tx > b { font-size: 15px; line-height: 21px; font-weight: 600; overflow-wrap: anywhere; text-wrap: pretty; }
.ceb-li__tx > span { font-size: 13px; line-height: 18px; color: var(--c-ink-2); overflow-wrap: anywhere; }
.ceb-li__tx > .ceb-li__meta { color: var(--c-ink-3); font-size: 12px; }
.ceb-li__val { display: flex; align-items: center; gap: 4px; flex: none; font-size: 13px; color: var(--c-ink-3); }
.ceb-li--bad { color: var(--c-bad); }
.ceb-li--bad .ceb-li__ic { background: var(--c-bad-bg); color: var(--c-bad); }

.ceb-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.ceb-row + .ceb-row { border-top: 1px solid var(--c-line); }
.ceb-row { flex-wrap: wrap; }
.ceb-row > .ceb-li__tx { flex: 1 1 180px; }
.ceb-row__act { display: flex; gap: 8px; margin-left: auto; }

.ceb-empty { display: grid; justify-items: center; gap: 6px; padding: 32px 24px; text-align: center; background: var(--c-card); border-radius: var(--r); box-shadow: var(--c-shadow); }
.ceb-empty b { font-size: 15px; font-weight: 700; }
.ceb-empty span:last-child { font-size: 14px; line-height: 20px; color: var(--c-ink-2); max-width: 300px; }
.ceb-empty .ceb-li__ic { margin-bottom: 6px; }

.ceb-alert { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-radius: var(--r-sm); background: var(--c-soft-2); color: var(--c-ink); font-size: 14px; line-height: 20px; }
.ceb-alert--info { background: var(--c-card); box-shadow: var(--c-shadow); margin-bottom: 16px; }
.ceb-alert__tx { flex: 1; min-width: 0; }
.ceb-alert__tx svg { display: inline-block; vertical-align: -3px; }
.ceb-alert b { font-weight: 700; }

.ceb-skel-list { display: grid; padding: 8px 16px; }
.ceb-skel { display: block; height: 48px; margin: 8px 0; border-radius: 12px; background: linear-gradient(90deg, var(--c-soft) 0%, #F7FBFE 50%, var(--c-soft) 100%); background-size: 200% 100%; animation: ceb-skel 1.4s ease-in-out infinite; }

.ceb-state { min-height: 78dvh; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 24px; text-align: center; color: var(--c-ink-2); }
.ceb-state p { margin: 0; max-width: 280px; }
.ceb-state .ceb-btn { margin-top: 12px; }

/* ---------- lưới 4 ngăn của anh ---------- */
.ceb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ceb-tile {
  display: grid; justify-items: start; align-content: start; gap: 2px; min-height: 140px; padding: 16px;
  text-align: left; border-radius: var(--r); background: var(--c-card); box-shadow: var(--c-shadow);
  transition: transform 150ms var(--spring), box-shadow 200ms;
}
.ceb-tile:active:not(:disabled) { transform: scale(0.97); box-shadow: var(--c-shadow-lift); }
.ceb-tile:disabled { opacity: .6; }
.ceb-tile .ceb-li__ic { background: var(--c-pastel); color: var(--c-ink); margin-bottom: 18px; }
.ceb-tile__label { font-size: 19px; line-height: 24px; font-weight: 800; letter-spacing: -0.01em; color: var(--c-ink); }
.ceb-tile__n { font-size: 13px; color: var(--c-ink-2); font-variant-numeric: tabular-nums; }

/* ---------- thanh tab đáy, nút thêm nổi ---------- */
.ceb-nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px; padding: 8px max(12px, calc(50% - 248px)) calc(8px + var(--safe-b)); background: rgba(255, 255, 255, .94);
  box-shadow: 0 -1px 0 var(--c-line), 0 -8px 24px -16px rgba(43, 92, 126, .25);
}
.ceb-nav__btn { position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; height: 54px; border-radius: 14px; font-size: 12px; font-weight: 600; color: var(--c-ink-2); transition: background-color 200ms, color 200ms; }
.ceb-nav__btn[aria-current="page"] { background: var(--c-soft-2); color: var(--c-ink); }
.ceb-nav__dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-love); color: var(--c-love-ink); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.ceb-dock { position: fixed; z-index: 20; left: 50%; bottom: calc(var(--safe-b) + 16px); transform: translateX(-50%); }
.ceb-dock .ceb-btn { box-shadow: var(--c-shadow-lift); }

/* ---------- bảng trượt ---------- */
.ceb-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(18, 50, 71, .32); animation: ceb-fade 240ms ease both; }
.ceb-scrim--deep { background: rgba(18, 50, 71, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.ceb-sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: var(--kb); margin: 0 auto; max-width: 520px;
  max-height: calc(100dvh - var(--kb) - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 20px calc(20px + var(--safe-b)); background: var(--c-card); border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 36px -10px rgba(18, 50, 71, .25); animation: ceb-up 380ms var(--spring) both;
}
.ceb-sheet__grip { display: block; width: 40px; height: 5px; margin: 0 auto 16px; border-radius: 3px; background: var(--c-soft-2); }
.ceb-sheet > .ceb-hl { margin-bottom: 4px; overflow-wrap: anywhere; }
.ceb-sheet__text { margin: 6px 0 16px; color: var(--c-ink-2); font-size: 14px; line-height: 21px; white-space: pre-line; overflow-wrap: anywhere; }

.ceb-form { display: grid; gap: 16px; }
.ceb-fl { display: grid; gap: 8px; }
.ceb-fl[hidden] { display: none; }
.ceb-field {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; border-radius: var(--r-sm);
  background: var(--c-bg); color: var(--c-ink-2); box-shadow: inset 0 0 0 1px var(--c-line); transition: box-shadow 200ms, background-color 200ms;
}
.ceb-field:focus-within { background: var(--c-card); box-shadow: inset 0 0 0 2px var(--c-pastel), 0 0 0 4px var(--c-soft); }
.ceb-field input, .ceb-field textarea { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--c-ink); font-size: 16px; padding: 14px 0; resize: none; }
.ceb-field input::placeholder, .ceb-field textarea::placeholder { color: var(--c-ink-3); }
.ceb-field--area { align-items: flex-start; }
.ceb-form__row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 4px; }
.ceb-one, .ceb-many { display: grid; gap: 16px; }
.ceb-one[hidden], .ceb-many[hidden] { display: none; }
.ceb-seg--mode { background: var(--c-card); box-shadow: inset 0 0 0 1px var(--c-line); }
.ceb-seg--mode > [aria-checked="true"] { background: var(--c-soft-2); }

/* Xem trước khi thêm nhiều món */
.ceb-pv:empty { display: none; }
.ceb-pv { display: grid; gap: 8px; }
.ceb-pv__head { margin: 0; font-size: 14px; font-weight: 700; color: var(--c-ink); }
.ceb-pv__list { list-style: none; margin: 0; padding: 4px 12px; border-radius: var(--r-sm); background: var(--c-bg); }
.ceb-pv__row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 0; }
.ceb-pv__row + .ceb-pv__row { border-top: 1px solid var(--c-line); }
.ceb-pv__tx { flex: 1; min-width: 0; display: grid; }
.ceb-pv__tx b { font-size: 15px; line-height: 20px; font-weight: 600; overflow-wrap: anywhere; }
.ceb-pv__tx span { font-size: 13px; line-height: 18px; color: var(--c-ink-2); overflow-wrap: anywhere; }
.ceb-pv__row.is-had .ceb-pv__tx { opacity: .55; text-decoration: line-through; }
.ceb-pv__had { flex: none; font-size: 12px; font-weight: 600; color: var(--c-ink-2); }
/* select cỡ 16px để iPhone không tự phóng to khi chạm */
.ceb-pv__cat {
  flex: none; height: 36px; padding: 0 28px 0 12px; border: 0; border-radius: 10px; background: var(--c-soft-2) no-repeat right 8px center / 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B5C7E' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color: var(--c-ink); font: 600 16px/1 var(--font); appearance: none; -webkit-appearance: none; cursor: pointer;
}

/* ---------- thẻ lật ra món ---------- */
.ceb-reveal {
  position: fixed; z-index: 41; inset: 0; display: grid; align-content: center; justify-items: center; gap: 14px;
  padding: calc(64px + var(--safe-t)) 20px calc(24px + var(--safe-b)); pointer-events: none;
}
.ceb-reveal > * { pointer-events: auto; }
.ceb-flip { position: relative; width: min(100%, 360px); display: grid; transform-style: preserve-3d; transform: rotateY(180deg); transition: transform .65s var(--spring); }
.ceb-flip.is-shown { transform: rotateY(0); }
.ceb-face { grid-area: 1 / 1; min-height: 330px; border-radius: 28px; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 24px 56px -18px rgba(18, 50, 71, .45); }
.ceb-face--back { display: grid; place-items: center; transform: rotateY(180deg); background: var(--c-pastel); }
.ceb-face--front { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 24px; color: var(--c-ink); background: linear-gradient(165deg, #FFFFFF 0%, #E3F2FC 45%, #BFE0F5 100%); }
.ceb-mark--glass { width: 88px; height: 88px; border-radius: 28px; background: rgba(255, 255, 255, .35); }
.ceb-face__over { display: flex; width: 100%; justify-content: space-between; gap: 8px; margin: 0; font-size: 13px; font-weight: 700; color: var(--c-ink-2); }
.ceb-face__over span { font-weight: 500; }
.ceb-face__ic { display: grid; place-items: center; width: 56px; height: 56px; margin: 14px 0 6px; border-radius: 18px; background: var(--c-pastel); color: var(--c-ink); }
.ceb-face__name { margin: 0; font-size: 30px; line-height: 36px; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; text-wrap: balance; }
.ceb-face__note { margin: 0; font-size: 15px; line-height: 22px; color: var(--c-ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.ceb-face__meta { margin: auto 0 0; padding-top: 12px; font-size: 13px; color: var(--c-ink-2); }
.ceb-reveal__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 360px); }
.ceb-reveal__close { position: fixed; top: calc(14px + var(--safe-t)); right: 16px; }

/* ---------- thông báo nhanh ---------- */
.ceb-toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--safe-b) + 84px); transform: translate(-50%, 12px);
  width: max-content; max-width: calc(100% - 40px); padding: 12px 18px; border-radius: var(--r-sm); background: var(--c-ink); color: #FFFFFF;
  font-size: 14px; font-weight: 500; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--spring);
  box-shadow: var(--c-shadow-lift);
}
.ceb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
/* Đang mở bảng trượt: đẩy lên đầu màn để không đè nút trong bảng. */
body.is-locked .ceb-toast { bottom: auto; top: calc(var(--safe-t) + 14px); }

@keyframes ceb-fade { from { opacity: 0; } }
@keyframes ceb-up { from { transform: translateY(100%); } }
@keyframes ceb-skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (min-width: 640px) {
  .ceb-sheet { bottom: calc(var(--kb) + 24px); border-radius: 24px; animation: ceb-fade 240ms ease both; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
