:root {
  --bg: #fff7ec;
  --bg2: #ffe9ef;
  --card: #ffffff;
  --text: #3a2e39;
  --muted: #8a7a88;
  --line: #f1e3e6;
  --brand: #ff6f8e;
  --brand-soft: #ffe1e8;
  --ok: #2f9e5b;
  --ok-soft: #e3f6ea;
  --warn: #c2410c;
  --warn-soft: #fff0e6;
  --danger: #d32f2f;
  --shadow: 0 2px 10px rgba(90, 40, 60, .08);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1719; --bg2: #2a1f24; --card: #2a2226; --text: #f6ecef; --muted: #b8a7ad; --line: #3b3035;
    --brand: #ff8fa3; --brand-soft: #4a2c35; --ok: #5fd08d; --ok-soft: #1f3a2b; --warn: #ffab70; --warn-soft: #43301f;
    --danger: #ff7a7a; --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --bg: #1d1719; --bg2: #2a1f24; --card: #2a2226; --text: #f6ecef; --muted: #b8a7ad; --line: #3b3035;
  --brand: #ff8fa3; --brand-soft: #4a2c35; --ok: #5fd08d; --ok-soft: #1f3a2b; --warn: #ffab70; --warn-soft: #43301f;
  --danger: #ff7a7a; --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.splash { display: grid; place-items: center; min-height: 80vh; font-weight: 700; font-size: 20px; }
.splash img { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* thanh trên */
.top {
  display: flex; align-items: center; gap: 10px; padding: 14px 0 10px;
  position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 85%, transparent));
  backdrop-filter: blur(6px);
}
.top .title { flex: 1; min-width: 0; }
.top .title h1 { font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: var(--card); color: var(--text); width: 40px; height: 40px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 18px; cursor: pointer; display: grid; place-items: center; flex: none;
}
.logo { width: 36px; height: 36px; border-radius: 10px; flex: none; }

/* thẻ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 6px; }

/* nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 15px; padding: 11px 18px; border-radius: 14px;
  background: var(--brand); color: #fff; min-height: 44px;
}
.btn.secondary { background: var(--brand-soft); color: var(--text); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ô nhập */
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=email], input[type=password], input[type=time], select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; line-height: 1.45; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--brand); margin-top: 1px; }

/* bé */
.kid { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.avatar {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; flex: none;
  background: var(--brand-soft);
}
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* tab */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 999px;
  background: var(--card); color: var(--muted); cursor: pointer; box-shadow: var(--shadow);
}
.tab[aria-selected="true"] { background: var(--brand); color: #fff; }

/* nhật ký */
.event { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event .ico { font-size: 22px; width: 30px; text-align: center; flex: none; }
.event .t { font-weight: 600; overflow-wrap: anywhere; }
.event .d { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; margin-top: 2px; }
.event .when { color: var(--muted); font-size: 12px; margin-top: 4px; }
.event.alert .t { color: var(--warn); }

/* chat */
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.days .tab { box-shadow: none; border: 1px solid var(--line); }
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.bubble.assistant { align-self: flex-start; background: var(--bg2); border-bottom-left-radius: 6px; }
.bubble .time { display: block; font-size: 11px; opacity: .7; margin-top: 3px; }

/* danh sách chỉnh sửa */
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.notice { border-radius: 14px; padding: 12px 14px; background: var(--warn-soft); color: var(--text); line-height: 1.5; }
.notice.ok { background: var(--ok-soft); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

/* đăng nhập */
.hero { text-align: center; padding: 48px 4px 8px; }
.hero img { width: 96px; height: 96px; border-radius: 26px; box-shadow: var(--shadow); }
.hero h1 { font-size: 32px; margin-top: 14px; }
.hero p { color: var(--muted); font-size: 16px; margin: 6px 0 0; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 22px 0; }
.feature { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); font-size: 14px; }
.feature b { display: block; font-size: 22px; margin-bottom: 4px; }
#gbtn { display: flex; justify-content: center; min-height: 44px; margin: 8px 0; }

ol.steps { padding-left: 22px; line-height: 1.7; margin: 8px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 500;
  transition: transform .25s; max-width: calc(100% - 32px); z-index: 20; text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }
