/* ตัวจิ๋ว – โทนน้ำตาล + ชมพู (latte & rose) */
:root {
  --brown: #8B5E4B;
  --brown-dark: #6B4636;
  --brown-deep: #4A332A;
  --pink: #E59BA6;
  --pink-soft: #F6D6DB;
  --pink-deep: #D87E8C;
  --cream: #FBF2EB;
  --cream-2: #F4E7DC;
  --card: #FFFFFF;
  --beige: #F0E2D6;
  --muted: #A38C7E;
  --line: #EADBCD;
  --mint: #8FC9B6;
  --amber: #E9B26A;
  --danger: #D9737A;
  --ok: #7FB98E;
  --shadow: 0 6px 20px rgba(122, 84, 64, 0.10);
  --shadow-soft: 0 8px 22px rgba(170, 140, 130, 0.14);
  --radius: 20px;
  --radius-sm: 14px;
  --maxw: 480px;

  /* พาสเทลนุ่ม ๆ (สำหรับการ์ดสถิติ/ปุ่มลัด) — โทน "ตัวอย่าง" */
  --sky-bg:   linear-gradient(150deg, #EEF6FE 0%, #DCEBFB 100%);  --sky-ink:   #5E8AB6;
  --mint-bg:  linear-gradient(150deg, #E9F8F0 0%, #D5F0E2 100%);  --mint-ink:  #4CA085;
  --lilac-bg: linear-gradient(150deg, #F4EEFD 0%, #E7DEFA 100%);  --lilac-ink: #8B72C4;
  --peach-bg: linear-gradient(150deg, #FEF3EA 0%, #FBE0CE 100%);  --peach-ink: #CB7F49;
  --rose-bg:  linear-gradient(150deg, #FDEEF2 0%, #FBDCE6 100%);  --rose-ink:  #CE6E8B;
  --font: "Noto Sans Thai", "Sukhumvit Set", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--brown-deep);
  line-height: 1.6;
  font-size: 16px;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
a { color: var(--pink-deep); }

/* ===== Layout (เลื่อนแบบเอกสารปกติ — เสถียรบนมือถือทุกเครื่อง) ===== */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream);
  position: relative;
  padding-bottom: 86px;   /* เผื่อพื้นที่ให้แถบเมนูล่าง (position: fixed) */
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, #FFFDFB 0%, #FBF3EC 100%);
  color: var(--brown-deep);
  padding: calc(11px + env(safe-area-inset-top, 0px)) 13px 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #F1E6DA;
}
.appbar .brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.appbar .brand .mark {
  width: 38px; height: 38px; border-radius: 13px; flex: 0 0 auto; overflow: hidden;
  background: linear-gradient(135deg, #FBE3EA 0%, #F7E7D8 100%);
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 3px 9px rgba(200, 150, 135, .20);
}
.appbar .brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.appbar .brand .bt { min-width: 0; }
.appbar .brand .tt {
  font-size: 18px; font-weight: 800; color: var(--brown-deep); white-space: nowrap;
  line-height: 1.12; display: flex; align-items: center; gap: 4px; letter-spacing: .2px;
}
.appbar .brand .tt i { font-size: 13px; font-style: normal; }
.appbar .brand .sub { font-size: 10.5px; color: var(--muted); font-weight: 600; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .spacer { flex: 1; }

/* ปุ่มพิลบนแถบบน (แจ้งเตือน / ตั้งค่า) */
.pill-btn {
  position: relative; background: #fff; border: 1px solid #F0E2D6;
  color: var(--brown-dark); border-radius: 999px; padding: 8px 11px;
  font-size: 12px; font-weight: 700; flex: 0 0 auto;
  display: flex; align-items: center; gap: 4px;
  box-shadow: 0 2px 8px rgba(122, 84, 64, .08);
  transition: transform .08s;
}
.pill-btn:active { transform: scale(.94); }
.pill-btn .badge-dot {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1; display: grid; place-items: center;
  border: 2px solid #fff;
}
/* ปุ่มสลับลูก (โผล่เมื่อมีหลายคน/มีครรภ์ด้วย) */
.mini-switch {
  background: #fff; border: 1px solid #F0E2D6; border-radius: 999px;
  padding: 4px 8px 4px 5px; display: flex; align-items: center; gap: 3px; flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(122, 84, 64, .08); font-size: 17px;
}
.mini-switch small { font-size: 10px; color: var(--muted); }
/* จอแคบ (เครื่องเล็ก/มีปุ่มสลับลูก) — ย่อให้พอดี ไม่ล้น */
@media (max-width: 384px) {
  .appbar { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .appbar .brand .sub { display: none; }
  .pill-btn { padding: 8px 10px; font-size: 12px; }
  .pill-btn span { display: none; }   /* เหลือไอคอน กันล้นจอ */
}

/* ไม่ใส่ animation/transform ที่ตัวเลื่อนเนื้อหา — กันบั๊ก iOS Safari ที่หน้ายาว ๆ แล้ว
   เนื้อหาช่วงล่าง "ไม่ถูกวาด/ขาว" (การ์ดขึ้นแค่ไม่กี่ใบแล้วว่าง) */
.view { padding: 16px 16px 8px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== iPad / จอใหญ่: ทำให้คอลัมน์แอปดู "ตั้งใจ" ไม่โล่ง =====
   พื้นหลังข้าง ๆ เป็นกราเดียนต์สีแบรนด์ + เงารอบคอลัมน์ ให้ดูเหมือนแผงแอปกึ่งกลาง */
@media (min-width: 700px) {
  :root { --maxw: 540px; }
  body {
    background: linear-gradient(160deg, var(--brown) 0%, #A06F58 45%, var(--pink-deep) 120%);
    background-attachment: fixed;
  }
  #app {
    box-shadow: 0 0 55px rgba(74, 51, 42, 0.40);
  }
  /* แถบเมนูล่างยังตรึงกึ่งกลาง (กว้างเท่าคอลัมน์) ขอบบนชัดขึ้นบนพื้นกราเดียนต์ */
  .tabbar { box-shadow: 0 -2px 18px rgba(74, 51, 42, 0.22); }
}

.section-title {
  font-size: 15px; font-weight: 700; color: var(--brown-dark);
  margin: 18px 4px 10px; display: flex; align-items: center; gap: 7px;
}
.section-title .more { margin-left: auto; font-size: 13px; color: var(--pink-deep); font-weight: 600; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.card.flat { box-shadow: none; }
.card.tint { background: linear-gradient(135deg, #FFF8F3, #FCEEE6); }
.card.onboard { border: 1.5px solid var(--brown); }

/* Hero / banner */
.hero {
  background: linear-gradient(135deg, #FEF4EC 0%, #FCEAF0 52%, #F4ECFC 100%);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  border: 1px solid #F7E6DE;
  display: flex; align-items: center; gap: 15px;
  margin-bottom: 16px;
  position: relative; overflow: hidden;
}
.hero .hero-deco { position: absolute; top: 0; right: 0; width: 150px; height: 100%;
  pointer-events: none; opacity: .9; }
.hero .emoji {
  width: 66px; height: 66px; border-radius: 50%; flex: 0 0 auto;
  background: #fff; box-shadow: 0 5px 14px rgba(190, 150, 155, .28), inset 0 0 0 3px rgba(255,255,255,.6);
  display: grid; place-items: center; font-size: 36px; position: relative; z-index: 1;
}
.hero > div { position: relative; z-index: 1; }
.hero h2 { margin: 0 0 2px; font-size: 20px; color: var(--brown-deep); font-weight: 800; }
.hero p { margin: 0; color: #9a7d6f; font-size: 13.5px; }
.hero .big { font-size: 26px; font-weight: 800; color: var(--pink-deep); line-height: 1.1; }
.hero .switch-hint { font-size: 11px; color: var(--pink-deep); font-weight: 700; margin-top: 5px; }

/* progress ring style bar */
.bigweek {
  display: flex; align-items: baseline; gap: 8px; margin-top: 4px;
}
.bigweek b { font-size: 40px; color: var(--brown); font-weight: 800; line-height: 1; }
.bigweek small { color: var(--muted); }

.progress {
  height: 10px; background: var(--cream-2); border-radius: 999px; overflow: hidden; margin-top: 10px;
}
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--brown)); border-radius: 999px; }

/* ===== การ์ดสถิติ 3 ใบ (พาสเทล) ===== */
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; margin-bottom: 14px; }
.s3 {
  border-radius: 20px; padding: 13px 6px 12px; text-align: center;
  border: 1px solid rgba(255,255,255,.55); box-shadow: var(--shadow-soft);
  transition: transform .08s; cursor: pointer;
}
.s3:active { transform: scale(.96); }
.s3 .ic { width: 40px; height: 40px; margin: 0 auto 7px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; background: rgba(255,255,255,.7); }
.s3 .v { font-size: 24px; font-weight: 800; line-height: 1; }
.s3 .v small { font-size: 13px; font-weight: 700; opacity: .65; }
.s3 .l { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.s3 .sub { font-size: 10.5px; opacity: .7; margin-top: 1px; }
.s3.sky   { background: var(--sky-bg);   color: var(--sky-ink); }
.s3.mint  { background: var(--mint-bg);  color: var(--mint-ink); }
.s3.lilac { background: var(--lilac-bg); color: var(--lilac-ink); }

/* ===== Quick actions grid (การ์ดขาว + ไอคอนในวงกลมพาสเทล) ===== */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick {
  background: #fff; border: none; border-radius: 20px;
  padding: 14px 6px 12px; text-align: center; box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: transform .08s;
}
.quick:active { transform: scale(.93); }
.quick .ic { width: 54px; height: 54px; border-radius: 50%; font-size: 27px;
  display: grid; place-items: center; background: #F4ECE6; }
.quick .lb { font-size: 12.5px; font-weight: 700; color: var(--brown-dark); }
.quick.rose  .ic { background: var(--rose-bg); }
.quick.lilac .ic { background: var(--lilac-bg); }
.quick.sky   .ic { background: var(--sky-bg); }
.quick.peach .ic { background: var(--peach-bg); }
.quick.mint  .ic { background: var(--mint-bg); }

/* stat chips (วันนี้) — ไอคอนซ้าย + ตัวเลข */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  border: none; border-radius: 20px; padding: 12px 8px; box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 8px;
}
.stat .ic { font-size: 26px; flex: 0 0 auto; line-height: 1; }
.stat .vwrap { min-width: 0; }
.stat .v { font-size: 22px; font-weight: 800; line-height: 1; }
.stat .l { font-size: 10.5px; font-weight: 700; margin-top: 2px; opacity: .85; }
.stat.rose  { background: var(--rose-bg);  color: var(--rose-ink); }
.stat.lilac { background: var(--lilac-bg); color: var(--lilac-ink); }
.stat.mint  { background: var(--mint-bg);  color: var(--mint-ink); }
.stat.sky   { background: var(--sky-bg);   color: var(--sky-ink); }

/* ปุ่มจับเวลา (พาสเทล) */
.tbtn { flex: 1; border: none; border-radius: 14px; padding: 12px 6px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 5px; transition: transform .08s; }
.tbtn:active { transform: scale(.95); }
.tbtn.rose  { background: var(--rose-bg);  color: var(--rose-ink); }
.tbtn.peach { background: var(--peach-bg); color: var(--peach-ink); }
.tbtn.lilac { background: var(--lilac-bg); color: var(--lilac-ink); }

/* รูปแทนตัวเป็นรูปถ่าย (เต็มกรอบ ตัดขอบตามพาเรนต์) */
.ava-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.mini-switch .ava { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 16px; background: linear-gradient(135deg, #FBE3EA, #F7E7D8); }
/* ตัวเลือกรูปแทนตัวในฟอร์มเพิ่ม/แก้ไขลูก */
.ava-row { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.ava-preview { width: 62px; height: 62px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center; font-size: 33px; box-shadow: var(--shadow-soft);
  background: linear-gradient(135deg, #FBE3EA, #F7E7D8); }

/* ===== ไทม์ไลน์ประวัติ (หน้าหลัก) ===== */
.timeline .tl-item { display: flex; align-items: center; gap: 11px; position: relative;
  padding: 10px 0 10px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.timeline .tl-item.last { border-bottom: none; }
.timeline .tl-rail { position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline .tl-item:first-child .tl-rail { top: 50%; }
.timeline .tl-item.last .tl-rail { bottom: 50%; }
.timeline .tl-dot { position: absolute; left: -3px; top: 50%; transform: translateY(-50%);
  width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.timeline .ic { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 20px; background: #F4ECE6; }
.timeline .ic.rose { background: var(--rose-bg); } .timeline .ic.lilac { background: var(--lilac-bg); }
.timeline .ic.sky { background: var(--sky-bg); } .timeline .ic.peach { background: var(--peach-bg); }
.timeline .ic.mint { background: var(--mint-bg); }
.timeline .body { flex: 1; min-width: 0; }
.timeline .body .t { font-weight: 700; font-size: 14px; color: var(--brown-deep); line-height: 1.4; }
.timeline .body .s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.timeline .meta { font-size: 12px; color: var(--muted); text-align: right; flex: 0 0 auto; line-height: 1.55; }
.timeline .meta .del { color: #D9737A; font-size: 11px; }
/* variant: ไอคอนสี่เหลี่ยมมน (พัฒนาการ/วัคซีน) */
.timeline.ms .ic, .timeline.sq .ic { border-radius: 14px; }
.timeline .ic.done { background: #E6F3E9; }
/* พัฒนาการ: หมวดใต้ชื่อเป็นสีชมพู */
.timeline.ms .body .s { font-size: 12px; font-weight: 700; color: var(--pink-deep); }
.timeline .chev { color: var(--pink-deep); font-size: 20px; flex: 0 0 auto; }

/* ===== การ์ดบทความ (ไอคอนวงกลมพาสเทลตามหมวด) ===== */
.art-item { display: flex; align-items: center; gap: 13px; cursor: pointer; }
.art-item .ic { width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 26px; background: #F4ECE6; }
.art-item.rose .ic { background: var(--rose-bg); } .art-item.peach .ic { background: var(--peach-bg); }
.art-item.mint .ic { background: var(--mint-bg); } .art-item.lilac .ic { background: var(--lilac-bg); }
.art-item.sky .ic { background: var(--sky-bg); }
.art-item .body { flex: 1; min-width: 0; }
.art-item .body .t { font-weight: 700; font-size: 15px; color: var(--brown-deep); line-height: 1.4; }
.art-item .body .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.art-item .chev { color: var(--pink-deep); font-size: 22px; flex: 0 0 auto; }

/* ===== การ์ดโภชนาการ (สารอาหารเด่นช่วงนี้) ===== */
.nut-card { padding: 16px; }
.nut-head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.nut-head .ic { width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 26px; background: var(--rose-bg); }
.nut-head .t { font-weight: 800; font-size: 17px; color: var(--brown-deep); }
.nut-head .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.nut-inner { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 6px 14px; }
.nut-sec { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; }
.nut-sec + .nut-sec { border-top: 1px solid var(--line); }
.nut-sec .ic { width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto; display: grid; place-items: center; font-size: 22px; }
.nut-sec .ic.sky { background: var(--sky-bg); } .nut-sec .ic.amber { background: #FBEFD0; } .nut-sec .ic.rose { background: #FCE0E2; }
.nut-sec .b { flex: 1; min-width: 0; }
.nut-sec .h { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.nut-sec ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.65; color: #5a463c; }
.nut-sec li { margin-bottom: 2px; }
.nut-note { display: flex; gap: 9px; align-items: flex-start; background: var(--rose-bg); border-radius: 13px;
  padding: 11px 13px; margin-top: 13px; font-size: 12.5px; color: #7a5a52; line-height: 1.5; }
.nut-note b { color: var(--rose-ink); }

/* chevron ในการ์ดเครื่องมือ (quick-grid.tools) */
.quick .tchev { align-self: stretch; text-align: center; color: var(--pink-deep); font-size: 15px; font-weight: 800;
  background: rgba(216,126,140,.09); border-radius: 10px; padding: 2px 0; margin-top: 3px; }

/* list item */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .ic {
  width: 42px; height: 42px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 21px; background: var(--cream-2);
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .body .t { font-weight: 600; font-size: 14.5px; }
.list-item .body .s { font-size: 12.5px; color: var(--muted); }
.list-item .meta { font-size: 12px; color: var(--muted); text-align: right; flex: 0 0 auto; }

/* badges */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; display: inline-block; }
.badge.due { background: #FCEAEB; color: var(--danger); }
.badge.soon { background: #FDF1E0; color: #B9802F; }
.badge.done { background: #E6F3E9; color: var(--ok); }
.badge.upcoming { background: var(--cream-2); color: var(--muted); }

/* ===== Buttons ===== */
.btn {
  border: none; border-radius: 14px; padding: 13px 18px; font-size: 15px; font-weight: 700;
  background: var(--brown); color: #fff; width: 100%;
  box-shadow: 0 4px 12px rgba(139, 94, 75, .28);
  transition: transform .08s, filter .1s;
}
.btn:active { transform: scale(.97); }
.btn.pink { background: var(--pink-deep); box-shadow: 0 4px 12px rgba(216,126,140,.3); }
.btn.ghost { background: var(--cream-2); color: var(--brown-dark); box-shadow: none; }
.btn.sm { width: auto; padding: 9px 16px; font-size: 13.5px; }
.btn.outline { background: #fff; color: var(--brown); border: 1.5px solid var(--brown); box-shadow: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: 100%; }

/* chips toggle */
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #FFFDFB);
  color: var(--brown-dark);
  border-radius: 999px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 2px 6px rgba(122, 84, 64, 0.07);
  transition: transform .12s ease, box-shadow .15s ease, background .18s ease, border-color .18s ease, color .18s ease;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.chip:active { transform: scale(.95); }
.chip.active {
  background: linear-gradient(135deg, var(--pink-soft) 0%, #FBE4E9 100%);
  border-color: var(--pink); color: var(--pink-deep);
  box-shadow: 0 3px 11px rgba(216, 126, 140, 0.24);
}
/* แถบเมนูหลัก "ความรู้" = หัวข้อหลักโทนน้ำตาล (แยกจากตัวกรองย่อยสีชมพู) */
.chips-main .chip { color: var(--brown-dark); font-weight: 700; }
.chips-main .chip.active {
  background: linear-gradient(135deg, var(--brown) 0%, var(--brown-dark) 100%);
  border-color: var(--brown-dark); color: #fff;
  box-shadow: 0 3px 12px rgba(107, 70, 54, 0.30);
}

/* forms */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--brown-dark); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--brown-deep); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--pink); }
.field .row { display: flex; gap: 10px; }
.field .row > * { flex: 1; }

/* ===== Bottom nav ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto;   /* จัดกลางด้วย margin (ไม่ใช้ transform → กันบั๊กวาดหน้า iOS) */
  width: 100%; max-width: var(--maxw);
  background: rgba(255,255,255,.97);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid #F1E6DA;
  display: flex; justify-content: space-around;
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  box-shadow: 0 -4px 18px rgba(107, 70, 54, 0.06);
}
.tabbar button {
  background: none; border: none; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #BBA595; font-size: 10.5px; font-weight: 700; padding: 4px 0;
  transition: color .15s;
}
.tabbar button .ic { line-height: 0; }
.tabbar button .ic svg { width: 25px; height: 25px; display: block; transition: transform .15s; }
.tabbar button.active { color: var(--pink-deep); }
.tabbar button.active .ic svg { transform: translateY(-1px); }

/* ===== ปุ่มไอคอนบนแถบบน + จุดแจ้งเตือน ===== */
.appbar .icon-btn {
  position: relative; background: rgba(255,255,255,.20); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%; font-size: 18px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.appbar .icon-btn .badge-dot {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1; display: grid; place-items: center;
  border: 2px solid #9C6A54;
}

/* ===== การ์ดสรุปภาพรวม (หน้าหลัก) ===== */
.summary-card {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-top: 14px;
}
.summary-card .su { text-align: center; padding: 14px 6px; }
.summary-card .su + .su { border-left: 1px solid var(--line); }
.summary-card .su .v { font-size: 24px; font-weight: 800; color: var(--brown); line-height: 1.1; }
.summary-card .su .v small { font-size: 14px; color: var(--muted); font-weight: 700; }
.summary-card .su .l { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ===== รายการแจ้งเตือน ===== */
.notif-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: none; }
.notif-item .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--cream-2); display: grid; place-items: center; font-size: 19px; flex: 0 0 auto; }
.notif-item .ic.due { background: #FCEAEB; }
.notif-item .ic.soon { background: #FBF0DE; }
.notif-item .body { flex: 1; min-width: 0; }
.notif-item .body .t { font-weight: 700; font-size: 14px; color: var(--brown-deep); }
.notif-item .body .s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.notif-item .chev { color: var(--pink-deep); font-size: 20px; flex: 0 0 auto; }

/* ===== Modal / sheet ===== */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(74,51,42,.45);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
.sheet {
  background: var(--cream); width: 100%; max-width: var(--maxw);
  border-radius: 24px 24px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom,0px));
  max-height: 88vh; overflow-y: auto;
  animation: slideup .25s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grab { width: 44px; height: 5px; background: var(--line); border-radius: 999px; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; color: var(--brown-deep); text-align: center; }

/* empty state */
.empty { text-align: center; color: var(--muted); padding: 30px 16px; }
.empty .em { font-size: 46px; }
.empty p { margin: 8px 0 16px; font-size: 14px; }

/* misc */
.muted { color: var(--muted); }
.center { text-align: center; }
.disclaimer {
  font-size: 11.5px; color: var(--muted); background: var(--cream-2);
  border-radius: 12px; padding: 10px 12px; margin: 8px 0;
  border: 1px dashed var(--line); line-height: 1.5;
}
.tag-week { font-size: 12px; color: var(--pink-deep); font-weight: 700; }
.fruit { font-size: 56px; text-align: center; margin: 6px 0; }
canvas { width: 100%; display: block; }

/* article reader */
.article h4 { color: var(--brown-deep); margin: 16px 0 6px; font-size: 16px; }
.article p { margin: 0 0 10px; font-size: 14.5px; color: #4f3d33; }
.article ul { margin: 0 0 10px; padding-left: 20px; }
.article li { margin-bottom: 4px; font-size: 14px; }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.scroll-x { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -4px; scroll-snap-type: x mandatory; }
.scroll-x::-webkit-scrollbar { display: none; }
.mini-card {
  flex: 0 0 auto; width: 140px; scroll-snap-align: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; box-shadow: var(--shadow);
}
.mini-card .em { font-size: 30px; }
.mini-card .t { font-weight: 700; font-size: 13px; margin-top: 6px; }
.mini-card .s { font-size: 11.5px; color: var(--muted); }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--brown-deep); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 200; box-shadow: var(--shadow);
  animation: fade .2s;
}

/* สวิตช์ เปิด/ปิด (toggle) */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; background: #D8C8BD;
  border-radius: 999px; transition: background .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 21px; width: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--pink-deep); }
.switch input:checked + .slider::before { transform: translateX(19px); }
