/* DPTN Pharmacy+ — สีจากโลโก้ (ม่วง + ฟ้าอมเขียว) ออกแบบสำหรับ iPad mini และ iPhone */
:root {
  --cream: #fff9f0;
  --card: #ffffff;
  --ink: #303a38;
  --muted: #75827c;
  --line: #ece8dc;
  --brand: #0a7f82;
  --brand-dark: #075b5e;
  --brand-soft: #dcf3f3;
  --teal: #04adaf;
  --purple: #86297f;
  --purple-soft: #f4e6f2;
  --orange: #86297f;
  --orange-soft: #f4e6f2;
  --green: #248d72;
  --green-bg: #e2f3ec;
  --yellow: #c98a00;
  --yellow-bg: #fff2cc;
  --red: #d64545;
  --red-bg: #ffe4e1;
  --blue: #3d6fd8;
  --blue-soft: #e3ecfb;
  --radius: 26px;
  --shadow: 0 2px 0 rgba(48, 58, 56, .06), 0 8px 24px rgba(48, 58, 56, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: "IBM Plex Sans Thai Looped", "Thonburi", "Noto Sans Thai", system-ui, sans-serif;
  font-size: 18px; line-height: 1.55; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid #8fb0ee; outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: var(--red); font-weight: 700; min-height: 1.5em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  min-height: 48px; padding: 10px 18px; border-radius: 16px; font-weight: 700;
  background: var(--card); border: 2px solid var(--line); color: var(--ink); transition: transform .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.yellow { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { min-height: 64px; font-size: 22px; padding: 14px 28px; border-radius: 22px; }
.btn.block { width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 12px; border-radius: 99px; background: var(--yellow-bg); font-weight: 700; font-size: 16px; white-space: nowrap; }

/* ---------- kid app shell ---------- */
.kid-top {
  position: sticky; top: 0; z-index: 5; background: rgba(255, 249, 240, .94); backdrop-filter: blur(10px);
  padding: calc(10px + var(--safe-t)) 20px 10px; border-bottom: 1px solid var(--line);
}
.kid-top .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; }
.brand .logo { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 24px; }
.brand-logo { display: block; height: 40px; width: auto; }
.brand .sub { font-size: 15px; font-weight: 700; color: var(--purple); background: var(--purple-soft); border-radius: 99px; padding: 2px 10px; white-space: nowrap; }
.me { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; min-width: 0; }
.me span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 20px calc(110px + var(--safe-b)); }

.face { border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--blue-soft); box-shadow: 0 0 0 3px #fff, 0 2px 8px rgba(0,0,0,.12); }
.face-emoji { display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--brand-soft); }
.face-letter { display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; }

.hello { border-radius: var(--radius); padding: 18px 22px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; font-size: 22px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips button { flex: 0 0 auto; min-height: 44px; padding: 6px 18px; border-radius: 99px; background: #fff; border: 2px solid var(--line); font-weight: 700; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
.tile {
  background: var(--card); border: 3px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 8px 14px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 150px; color: var(--ink); transition: transform .12s;
}
.tile:active { transform: scale(.96); }
.tile .ic { font-size: 52px; line-height: 1; }
.tile .lb { font-weight: 800; font-size: 19px; line-height: 1.3; }
.tile .sub { font-size: 15px; color: var(--muted); font-weight: 600; }
.tile.green { background: var(--green-bg); border-color: #bfe3d4; }
.tile.yellow { background: var(--yellow-bg); border-color: #f3dc96; }
.tile.red { background: var(--red-bg); border-color: #f5b8b0; }
.kids-grid { --cols: 5; }
.sym-grid { --cols: 4; }
.who-grid { --cols: 2; }
.who-grid .tile { min-height: 230px; }
.who-grid .tile .ic { font-size: 84px; }
.who-grid .tile .lb { font-size: 28px; }

.section-title { font-size: 21px; font-weight: 800; margin: 24px 0 12px; display: flex; align-items: center; gap: 10px; }
.dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.banner { border-radius: var(--radius); padding: 18px 22px; font-size: 22px; font-weight: 800; display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.banner.red { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.banner.green { background: var(--green-bg); color: var(--brand-dark); }
.banner.yellow { background: var(--yellow-bg); color: #7a5400; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(214, 69, 69, .18); } }
@media (prefers-reduced-motion: reduce) { .banner.red { animation: none; } }

.case-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.steps { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; padding: 12px 10px 12px 12px; border-radius: 18px; margin-bottom: 8px; background: #f8f5ee; cursor: pointer; }
.steps li::before { content: counter(s); flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 800; display: grid; place-items: center; }
.steps li.done { opacity: .55; }
.steps li.done span { text-decoration: line-through; }
.steps li.done::before { content: '✓'; background: var(--green); }
.steps li span { flex: 1; }
.speak { font-size: 24px; min-width: 48px; min-height: 48px; border-radius: 14px; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item-row:first-of-type { border-top: 0; }
.item-row .ic { font-size: 38px; flex: 0 0 auto; }
.item-row .nm { flex: 1; font-weight: 700; min-width: 0; }
.status { font-weight: 800; white-space: nowrap; }
.status.pending, .status.coming { color: var(--yellow); }
.status.dispensed { color: var(--green); }
.status.rejected { color: var(--red); }
.danger-list { margin: 8px 0 14px; padding-left: 22px; }

.pin-wrap { max-width: 380px; margin: 10px auto 0; text-align: center; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.pinpad button { aspect-ratio: 1; border-radius: 50%; font-size: 32px; font-weight: 800; background: var(--card); box-shadow: var(--shadow); }
.pindots { display: flex; gap: 16px; justify-content: center; margin: 16px 0 6px; }
.pindots i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand); }
.pindots i.on { background: var(--brand); }

.sos-bar { position: fixed; right: 20px; bottom: calc(20px + var(--safe-b)); z-index: 6; }
.sos-bar .btn { box-shadow: 0 8px 24px rgba(214, 69, 69, .35); }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 18px; font-weight: 700; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30, 36, 35, .4); z-index: 25; display: grid; place-items: center; padding: 20px; }
.sheet { background: #fff; border-radius: var(--radius); padding: 22px; max-width: 460px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.big-emoji { font-size: 96px; line-height: 1.1; }

/* iPad mini แนวนอน */
@media (min-width: 1000px) {
  .kids-grid { --cols: 6; }
  .sym-grid { --cols: 5; }
  .case-grid { grid-template-columns: 1.25fr 1fr; align-items: start; }
}
/* iPad mini แนวตั้ง (744–834) */
@media (max-width: 860px) {
  .kids-grid { --cols: 4; }
  .sym-grid { --cols: 4; }
}
/* iPhone */
@media (max-width: 560px) {
  body { font-size: 17px; }
  .wrap { padding: 14px 14px calc(96px + var(--safe-b)); }
  .kid-top { padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 19px; }
  .brand-logo { height: 32px; }
  .grid { gap: 10px; }
  .kids-grid { --cols: 3; }
  .sym-grid { --cols: 2; }
  .who-grid { --cols: 1; }
  .who-grid .tile { min-height: 150px; flex-direction: row; gap: 18px; }
  .who-grid .tile .ic { font-size: 64px; }
  .tile { min-height: 124px; padding: 12px 6px; border-radius: 22px; }
  .tile .ic { font-size: 42px; }
  .tile .lb { font-size: 17px; }
  .hello, .banner { font-size: 19px; padding: 14px 16px; }
  .card { padding: 16px; border-radius: 22px; }
  .sos-bar { left: 14px; right: 14px; bottom: calc(12px + var(--safe-b)); }
  .sos-bar .btn { width: 100%; }
  .btn.big { font-size: 20px; min-height: 58px; }
}

/* ---------- แอปบน iOS (เพิ่มไปยังหน้าจอโฮม) ---------- */
html, body { overscroll-behavior-y: none; }
body { -webkit-touch-callout: none; }
.kids-grid, .sym-grid, .who-grid, .case-grid, .btn, .tile { -webkit-user-select: none; user-select: none; }
input, select, textarea { font-size: max(16px, 1em); } /* กัน iOS ซูมเองตอนแตะช่องกรอก */
.a2hs { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  width: min(480px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fff; border-radius: 20px; box-shadow: 0 10px 34px rgba(48,58,56,.22); font-size: 15px; line-height: 1.45; }
.a2hs img { border-radius: 12px; flex: 0 0 auto; }
.a2hs .txt { flex: 1; min-width: 0; }
.a2hs .x { width: 36px; height: 36px; border-radius: 99px; background: var(--line); font-size: 15px; flex: 0 0 auto; }
.has-sos .a2hs, body:has(.sos-bar) .a2hs, body:has(.bottom-nav) .a2hs { bottom: calc(96px + var(--safe-b)); }
.offline-bar { background: var(--yellow-bg, #fff3cd); color: #7a5400; font-weight: 700; text-align: center; padding: 8px 12px; border-radius: 14px; margin-bottom: 14px; }
