/* สไตล์ MedMind (หน้าจอจริงใน public/ ย้ายจากต้นแบบ M3) — โทนเขียวตามงานออกแบบของ Rossatorn การ์ดมุมมน (design-system.md §2)
 * ใช้ var(--token) จาก tokens.css เท่านั้น ห้ามใส่สี #hex ในไฟล์นี้ (ตรวจด้วย tests/prototype.test.js)
 * ขนาดตาม NFR-03: ตัวอักษร ≥ 18px · ชื่อยา ≥ 24px · ปุ่มกินแล้ว/ยังไม่กิน สูง ≥ 64px · พื้นที่แตะอื่น ≥ 48px */
/* ฟอนต์ Sarabun (SIL OFL 1.1 — fonts/OFL.txt) ไฟล์ในเครื่อง ไม่โหลดจากเน็ต · มาจากต้นแบบของ Rossatorn */
@font-face { font-family: "Sarabun"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-Regular.ttf") format("truetype"); }
@font-face { font-family: "Sarabun"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Sarabun"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-Bold.ttf") format("truetype"); }
@font-face { font-family: "Mali"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Mali-SemiBold.ttf") format("truetype"); } /* Mali (SIL OFL 1.1 — fonts/OFL-Mali.txt) หัวข้อแบบน่ารัก */
@font-face { font-family: "Mali"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Mali-Bold.ttf") format("truetype"); }
* { box-sizing: border-box; }
html { font-family: var(--font); }
body { margin: 0; min-height: 100vh; background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2)); color: var(--text); font-size: var(--fs-body); line-height: 1.5; }
h1 { font-size: var(--fs-h1); margin: 0 0 var(--space-1); line-height: 1.25; }
h2 { font-size: var(--fs-h2); margin: 0 0 var(--space-1); }
h3 { font-size: var(--fs-h2); margin: 0; }
p { margin: 0 0 var(--space-1); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); }
.ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- แถบควบคุมของผู้นำเสนอ (อยู่นอกจอมือถือ) ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: var(--space-2); }
.pagebar { background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.pagebar h1 { font-size: var(--fs-h2); }
.pagebar .covers { margin-top: var(--space-1); border: 0; background: var(--bg); padding: 0; border-radius: 0; }
.clockbar { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; margin-top: var(--space-1); }
.clockbar .time { font-size: var(--fs-h2); font-weight: bold; min-width: 8ch; color: var(--accent); }
.clockbar .tb { min-height: var(--tap-min); padding: 0 var(--space-2); border: 2px solid var(--primary); background: var(--bg); color: var(--primary); border-radius: 999px; cursor: pointer; font-weight: bold; }
.clockbar .tb:hover { background: var(--accent-soft); }
.clockbar label { display: inline-flex; gap: var(--space-1); align-items: center; min-height: var(--tap-min); }
.clockbar .tb-input { min-height: var(--tap-min); width: 12ch; border: 2px solid var(--text-muted); border-radius: var(--radius); background: var(--bg); padding: 0 var(--space-1); font-variant-numeric: tabular-nums; }
.clockbar .tb-input[aria-invalid="true"] { border-color: var(--notyet); }
.clockbar select { min-height: var(--tap-min); border: 2px solid var(--text-muted); border-radius: var(--radius); background: var(--bg); padding: 0 var(--space-1); }
.note { color: var(--text-muted); }
.demo-banner { background: var(--warn-bg); color: var(--warn-text); padding: var(--space-1) var(--space-2); border-radius: 999px; font-weight: bold; margin-bottom: var(--space-1); display: inline-block; }
.phones { display: flex; flex-wrap: nowrap; gap: var(--space-3); justify-content: safe center; overflow-x: auto; padding-bottom: var(--space-1); } /* ผู้สูงอายุ | ผู้ดูแล อยู่ข้างกันเสมอ (จอแคบเลื่อนซ้าย-ขวาได้) */
.phone-wrap { flex: none; }
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.phone-wrap > h2 { font-size: var(--fs-body); color: var(--accent); margin: 0; background: var(--bg); padding: 0 var(--space-2); border-radius: 999px; box-shadow: var(--shadow); }
.rolebar { display: flex; gap: var(--space-1); justify-content: center; margin-bottom: var(--space-1); }
.rolebar button { min-height: var(--tap-min); padding: 0 var(--space-2); border: 2px solid var(--primary); background: var(--bg); color: var(--primary); border-radius: 999px; cursor: pointer; font-weight: bold; }
.rolebar button.is-on { background: var(--primary); border-color: var(--accent); color: var(--on-color); }

/* ---------- ตัวเครื่อง ---------- */
.phone { color: var(--text); font-size: var(--fs-body); width: 390px; max-width: 100%; height: 780px; background: var(--bg); border: 8px solid var(--bg); border-radius: 40px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.view { height: 100%; }
.phone-inner { display: flex; flex-direction: column; height: 100%; position: relative; background: linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2)); border-radius: 32px; overflow: hidden; }
.phone-inner.is-closed .screen { opacity: 0.5; }
.appbar { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-2); background: var(--primary); color: var(--on-color); min-height: 56px; }
.role-chip { background: var(--accent-soft); color: var(--primary); border-radius: 999px; padding: 0 var(--space-1); font-weight: bold; }
.appbar-title { flex: 1; font-weight: bold; }
.appbar-time { font-variant-numeric: tabular-nums; }
.role-navigation { padding: 0 var(--space-2); border-bottom: 1px solid var(--line); }
.role-navigation a { display: inline-flex; align-items: center; min-height: var(--tap-min); font-weight: bold; text-underline-offset: 3px; }
.covers { margin: var(--space-1) var(--space-2) 0; padding: 0 var(--space-1); background: var(--bg); color: var(--text-muted); border-radius: var(--radius); }
.screen { flex: 1; overflow-y: auto; padding: var(--space-2); }
.lead { color: var(--text-muted); }
.hint { color: var(--text-muted); }
.hint.ok { color: var(--taken); }
.error { color: var(--notyet); font-weight: bold; }

/* ---------- ภาพประกอบ (ไอคอน SVG วาดเอง ใช้สี token) ---------- */
.hero { text-align: center; margin-bottom: var(--space-2); }
.hero h1 { margin-top: var(--space-1); }
.brand { display: flex; align-items: center; justify-content: center; gap: var(--space-1); color: var(--primary); font-size: var(--fs-h1); font-weight: bold; }
.logo { width: 88px; height: 88px; }
.logo-sm { width: 48px; height: 48px; flex: none; }
.icon-circle { display: inline-flex; align-items: center; justify-content: center; width: 96px; height: 96px; border-radius: 50%; background: var(--bg); color: var(--accent); box-shadow: var(--shadow); }
.icon-circle .ico { width: 52px; height: 52px; stroke-width: 1.8; }
.greet { display: flex; align-items: center; gap: var(--space-2); background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2); margin-bottom: var(--space-2); }
.greet h1 { margin: 0; }
.greet p { margin: 0; color: var(--text-muted); }

/* ---------- คอมโพเนนต์ ---------- */
.card { background: var(--bg); border: 1px solid var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2); margin-bottom: var(--space-2); }
.card.center { text-align: center; }
.card.empty { text-align: center; color: var(--text-muted); }
.card.warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-bg); }
.card.ok-box { border: 2px solid var(--taken); }
.card-alert { border: 2px solid var(--notyet); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-1); margin-bottom: var(--space-1); }
.meal-h { margin-top: var(--space-1); color: var(--accent); }
.meds, .plain { list-style: none; padding: 0; margin: 0 0 var(--space-2); }
.meds li { display: flex; flex-direction: column; margin-bottom: var(--space-1); padding: var(--space-1) var(--space-2); background: var(--surface); border-radius: var(--radius); }
.med-name { font-size: var(--fs-med-name); font-weight: bold; line-height: 1.25; }
.med-qty { font-weight: bold; color: var(--primary); }
.med-note { color: var(--text-muted); }
.btn { display: flex; align-items: center; justify-content: center; gap: var(--space-1); width: 100%; min-height: var(--btn-h); margin: 0 0 var(--space-1); padding: 0 var(--space-2); border: 2px solid var(--primary); border-radius: 999px; background: var(--bg); color: var(--primary); font-weight: bold; cursor: pointer; text-align: center; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-color); }
.btn-taken { background: var(--taken); border-color: var(--taken); color: var(--on-color); }
.btn-notyet { background: var(--notyet); border-color: var(--notyet); color: var(--on-color); }
.btn-ghost { background: var(--bg); color: var(--primary); }
.btn-small { width: auto; min-height: var(--tap-min); margin: 0; }
.btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-color); }
.btn:disabled { background: var(--surface); border-color: var(--surface); color: var(--text-muted); cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .role-card:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-bottom: var(--space-1); }
.chip { display: inline-block; padding: 0 var(--space-1); border-radius: 999px; border: 2px solid var(--text-muted); font-weight: bold; background: var(--bg); }
.chip-taken { border-color: var(--taken); color: var(--taken); }
.chip-late { border-color: var(--warn-text); color: var(--warn-text); background: var(--warn-bg); }
.chip-notyet { border-color: var(--notyet); color: var(--notyet); }
.chip-none { color: var(--text-muted); }
.banner { background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius-lg); padding: var(--space-2); margin-bottom: var(--space-2); box-shadow: var(--shadow); }
.banner-ok { background: var(--bg); color: var(--text); border: 2px solid var(--taken); }
.banner .btn { margin-top: var(--space-1); }
.flag { color: var(--notyet); font-weight: bold; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-2); }
.field span { font-weight: bold; }
.field input, .field select { min-height: var(--tap-min); padding: 0 var(--space-2); border: 2px solid var(--text-muted); border-radius: var(--radius); background: var(--bg); width: 100%; }
.check { display: flex; gap: var(--space-1); align-items: center; min-height: var(--tap-min); margin-bottom: var(--space-1); }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.slot { border: 2px solid var(--surface); background: var(--bg); border-radius: var(--radius-lg); margin: 0 0 var(--space-2); padding: var(--space-2); }
.slot legend { font-weight: bold; padding: 0 var(--space-1); color: var(--accent); }
.code { font-size: var(--fs-h1); font-weight: bold; letter-spacing: 0.15em; color: var(--accent); }
.consent { padding-left: var(--space-3); margin: 0 0 var(--space-2); }
.qr { display: grid; grid-template-columns: repeat(13, 1fr); width: 200px; aspect-ratio: 1; margin: 0 auto var(--space-1); padding: 6px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.qr i { background: var(--bg); }
.qr i.on { background: var(--text); }
.role-card { display: flex; align-items: center; gap: var(--space-2); text-align: left; width: 100%; min-height: var(--btn-h); margin-bottom: var(--space-2); padding: var(--space-2); background: var(--bg); border: 2px solid var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); cursor: pointer; }
.role-card .ico { width: 40px; height: 40px; color: var(--accent); }
.role-card strong { display: block; font-size: var(--fs-h2); color: var(--primary); }
.label-mock { background: var(--bg); border: 2px dashed var(--text-muted); border-radius: var(--radius); padding: var(--space-2); margin-bottom: var(--space-2); }
.lm-title { font-weight: bold; }
.lm-part { text-decoration: underline; }
.lm-part.is-covered { background: var(--text); color: var(--text); display: inline-block; min-width: 6ch; text-decoration: none; border-radius: 4px; }
.spinner { width: 48px; height: 48px; margin: var(--space-3) auto; border: 6px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.tabs { display: flex; gap: 4px; padding: 6px; background: var(--bg); box-shadow: var(--shadow); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; padding: 4px; border: 0; border-radius: var(--radius); background: var(--bg); color: var(--text-muted); cursor: pointer; font-weight: bold; position: relative; }
.tab .ico { width: 30px; height: 30px; }
.tab-label { font-size: var(--fs-tab); font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tab:has(.tab-label) .ico { width: 26px; height: 26px; }
.tab.is-on { background: var(--accent-soft); color: var(--primary); }
.badge { position: absolute; top: 2px; right: 10px; min-width: 1.5em; background: var(--notyet); color: var(--on-color); border-radius: 999px; text-align: center; }
.toast-region { position: absolute; left: var(--space-2); right: var(--space-2); bottom: 92px; z-index: 5; }
.toast { display: flex; align-items: center; gap: var(--space-1); background: var(--text); color: var(--bg); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.toast span { flex: 1; }
.toast-close { min-height: var(--tap-min); min-width: var(--tap-min); padding: 0 var(--space-2); border: 2px solid var(--bg); border-radius: 999px; background: var(--text); color: var(--bg); font-weight: bold; cursor: pointer; }
.toast-close:focus-visible { outline: 3px solid var(--bg); outline-offset: 2px; }
.sound-bar { width: 100%; min-height: var(--tap-min); margin-bottom: var(--space-2); background: var(--warn-bg); color: var(--warn-text); border: 0; border-radius: 999px; font-weight: bold; cursor: pointer; }
.modal { position: absolute; inset: 0; background: var(--primary); display: flex; align-items: center; justify-content: center; padding: var(--space-2); }
.modal-box { background: var(--bg); border-radius: var(--radius-lg); padding: var(--space-3); width: 100%; text-align: center; }
.closed-note { text-align: center; padding: var(--space-3); }

/* ---------- ต่อยอดจากต้นแบบของ Rossatorn: การ์ดฮีโร่ มาสคอต วงแหวนสถานะ ป้ายรอบเตือน ---------- */
h1:focus-visible, h2:focus-visible { outline: 3px solid var(--text); outline-offset: 4px; border-radius: 4px; }
.mascot { flex: none; }
.hero .mascot { display: block; margin: 0 auto; }
.hero-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.hero-row h1 { margin: 0; }
.h-section { font-size: var(--fs-h2); }
.h-card { font-size: var(--fs-h2); margin: 0; }
.center { text-align: center; }
.disclaimer { color: var(--text-muted); text-align: center; margin-top: var(--space-2); }
.card.empty .mascot { display: block; margin: 0 auto var(--space-1); }
.hero-card { background: var(--hero-bg); color: var(--hero-text); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2) var(--space-2) var(--space-1); margin-bottom: var(--space-3); }
.hero-body { display: flex; align-items: center; gap: var(--space-1); }
.hero-text { flex: 1; min-width: 0; }
.hero-label { margin: 0; font-weight: 600; }
.hero-big { margin: 0 0 4px; font-size: var(--fs-h1); font-weight: bold; line-height: 1.25; }
.hero-sub { margin: 0 0 var(--space-1); }
.hero-card .btn { margin-top: var(--space-1); }
.hero-card .btn-taken { border-color: var(--taken); }
.hero-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); color: var(--text); border-radius: 999px; padding: 0 var(--space-1); font-weight: 600; }
.hero-chip .ico { width: 20px; height: 20px; color: var(--primary); }
.btn-light { background: var(--bg); border-color: var(--bg); color: var(--primary); }
.ring { --p: 0; flex: none; width: 104px; height: 104px; border-radius: 50%; padding: 8px; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--bg) 0); }
.ring span { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 50%; background: var(--bg); color: var(--text); line-height: 1.2; }
.ring b { font-size: var(--fs-h2); color: var(--taken); }
.sec-head { display: flex; justify-content: space-between; align-items: center; margin: var(--space-1) 0; }
.sec-head h2 { margin: 0; }
.count { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 var(--space-1); font-weight: 600; }
.remind { margin-bottom: var(--space-3); }
.round-pill { display: inline-flex; align-items: center; gap: var(--space-1); background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 4px var(--space-2); font-weight: bold; margin-bottom: var(--space-1); }
.choice { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-2) 0 var(--space-1); } /* แยกปุ่มเขียว/แดงให้ห่าง กันกดพลาด */
.choice .btn { margin: 0; }
.btn .ico { width: 26px; height: 26px; }
.label-says { background: var(--bg); border-left: 6px solid var(--accent); border-radius: var(--radius); padding: var(--space-1) var(--space-2); }
.med-warn { display: flex; align-items: flex-start; gap: var(--space-1); margin-top: 4px; background: var(--warn-bg); color: var(--warn-text); border-radius: var(--radius); padding: 4px var(--space-1); }
.med-warn .ico { margin-top: 2px; }
.alert-card { background: var(--bg); border: 2px solid var(--notyet); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2); margin-bottom: var(--space-2); }
.alert-card.alert-ok { border-color: var(--taken); }
.alert-head { display: flex; gap: var(--space-2); align-items: flex-start; margin-bottom: var(--space-1); }
.alert-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--warn-bg); color: var(--notyet); }
.alert-ico.ok { background: var(--surface); color: var(--taken); }
.sound-bar { display: flex; align-items: center; justify-content: center; gap: var(--space-1); }
.modal-box .mascot { display: block; margin: 0 auto; }

/* ---------- หน้าสารบัญ ---------- */
.journey { background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.journey h2 { margin-bottom: var(--space-1); color: var(--accent); }
.map { width: 100%; border-collapse: collapse; }
.map th, .map td { text-align: left; vertical-align: top; padding: var(--space-1); border-bottom: 1px solid var(--surface); }
.map a { color: var(--primary); font-weight: bold; }
.tag { display: inline-block; padding: 0 var(--space-1); margin: 2px 2px 2px 0; background: var(--accent-soft); border-radius: 999px; color: var(--accent); font-size: var(--fs-body); }
.linkrow { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.linkrow a { display: inline-flex; align-items: center; min-height: var(--tap-min); padding: 0 var(--space-2); border: 2px solid var(--primary); border-radius: 999px; color: var(--primary); font-weight: bold; text-decoration: none; background: var(--bg); }
.linkrow a.primary { background: var(--primary); border-color: var(--accent); color: var(--on-color); }

/* ตั้งค่าการแสดงผล: ปุ่มเลือกขนาดตัวอักษร / โหมดสี (สีและขนาดมาจาก token เท่านั้น) */
.pref-label { margin: var(--space-2) 0 var(--space-1); font-weight: 600; }
.seg { display: flex; gap: var(--space-1); }
.seg-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--space-1); min-height: var(--tap-min); border: 2px solid var(--text-muted); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn.is-on { background: var(--primary); border-color: var(--primary); color: var(--on-color); }
.seg-btn:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.stepper { display: flex; align-items: center; gap: var(--space-2); }
.step-btn { width: var(--tap-min); height: var(--tap-min); flex: none; display: grid; place-items: center; border: 2px solid var(--primary); border-radius: 50%; background: var(--bg); color: var(--primary); cursor: pointer; }
.step-btn .ico { width: 28px; height: 28px; }
.step-btn[aria-disabled="true"] { border-color: var(--text-muted); color: var(--text-muted); cursor: not-allowed; }
.step-btn:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.step-val { flex: 1; text-align: center; font-weight: 700; color: var(--text); }
.h-card .ico { margin-right: var(--space-1); vertical-align: -4px; }

/* จอแคบ (มือถือ): แถบสถานการณ์ไม่ล้นจอ — ชื่อสถานการณ์ยาวต้องย่อลงให้พอดี */
.clockbar label { flex-wrap: wrap; max-width: 100%; }
.clockbar select { max-width: 100%; min-width: 0; }

/* หน้าใช้งานจริงบนมือถือ (senior.html / caregiver.html): เต็มจอ ไม่มีกรอบเครื่อง */
body.real { background: var(--bg); }
/* แอปจริงพอดีจอมือถือเสมอ: ยึดขอบจอด้วย position: fixed (100vh บนมือถือสูงกว่าจอที่เห็น แถบเมนูล่างตกขอบ) · เลื่อนเฉพาะเนื้อหา .screen */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body.real { overflow: hidden; }
body.real .phone { position: fixed; top: 0; bottom: 0; left: 0; right: 0; width: auto; max-width: 640px; height: auto; margin: 0 auto; border: 0; border-radius: 0; box-shadow: none; }
body.real .screen { overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
body.real .tabs { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
body.real .phone-inner { border-radius: 0; padding-top: env(safe-area-inset-top); }
.qr-real { display: block; width: min(240px, 70vw); aspect-ratio: 1; margin: 0 auto var(--space-1); border-radius: var(--radius); box-shadow: var(--shadow); }

/* C-04 ใช้งานจริง: ลากนิ้ววาดแถบดำปิดชื่อ/HN บนรูปฉลาก (ภาพนี้คือภาพที่จะส่งจริง) */
.redact-stage { position: relative; touch-action: none; user-select: none; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: var(--space-2); cursor: crosshair; }
.redact-stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.redact-box, .redact-preview { position: absolute; background: var(--qr-dark); }
.redact-preview { opacity: 0.7; outline: 2px dashed var(--accent-soft); }

/* ---------- หน้าใช้งานจริง: ไม่แสดงป้าย Covers (ป้ายไว้ให้ผู้ตรวจดูใน Demo mode) · หน้าเลือกบทบาท ---------- */
body.real .covers { display: none; }
/* ---------- ทางเข้า (index.html): หน้าแรก + เลือกบทบาท ตามต้นแบบ ---------- */
.entry-body { background: var(--bg-grad-1); }
.entry-screen { max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.entry-screen[hidden] { display: none; }
.splash { background: var(--fresh); color: var(--text); text-align: center; max-width: none; }
.splash-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; max-width: 480px; margin: 0 auto; }
.splash-foot { width: 100%; max-width: 480px; margin: 0 auto; }
.splash .lead, .splash .fine { color: var(--text); }
.mascot-big { width: min(220px, 60vw); height: auto; margin-bottom: var(--space-3); }
.fine { color: var(--text-muted); text-align: center; font-size: var(--fs-body); }
.roles .brand { color: var(--primary); font-weight: bold; margin: 0 0 var(--space-3); }
.roles h1 { margin-bottom: var(--space-1); }
.role-card { display: block; text-decoration: none; color: var(--text); background: var(--bg); border: 2px solid var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: var(--space-3); margin: var(--space-2) 0 0; min-height: 120px; }
.role-card strong { display: block; font-size: var(--fs-h2); margin-bottom: var(--space-1); }
.role-card span { color: var(--text-muted); }
.role-card:active, .role-card:focus-visible { border-color: var(--primary); }
.roles .fine { margin-top: var(--space-3); }

/* ---------- สแกน QR ด้วยกล้อง (FR-01) ---------- */
.scan-overlay { position: fixed; inset: 0; z-index: 50; background: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-2) calc(var(--space-3) + env(safe-area-inset-bottom)); }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; top: 22%; left: 50%; width: min(70vw, 300px); aspect-ratio: 1; transform: translateX(-50%); border: 4px solid var(--accent-soft); border-radius: var(--radius-lg); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35); }
.scan-hint { position: relative; margin: 0; padding: var(--space-1) var(--space-2); border-radius: 999px; background: var(--bg); color: var(--text); font-weight: bold; text-align: center; }
.scan-close { position: relative; max-width: 480px; }

/* ---------- ธีมน่ารัก (7 พ.ย. 2569 · แคนวาส "MedMind แอปจริง — หน้าตา") ----------
 * พื้นครีม การ์ดขาวมีขอบ + เงาแข็งแบบสติกเกอร์ · หัวข้อฟอนต์ Mali · สีตามสถานะของมื้อ (ยืนยันแล้ว เขียว / ยังไม่ยืนยัน แดง / รอเวลา เหลือง / มื้อเย็น ม่วง)
 * สีมาจาก token เท่านั้น — คู่ตัวอักษร/พื้นตรวจ contrast ใน tests/publicPages.test.js */
h1, h2, h3, .h-card, .hero-big, .appbar-title, .brand, .entry-title { font-family: var(--font-head); }
.phone-inner { background: var(--bg-grad-1); }
.appbar { background: var(--bg-grad-1); color: var(--text); border-bottom: 2px solid var(--line); }
.appbar-title { font-size: var(--fs-h2); }
.card, .alert-card, .greet, .role-card, .slot, .modal-box, .journey, .label-mock { border: 2px solid var(--line); box-shadow: var(--shadow); }
.icon-circle { border: 2px solid var(--line); }
.meds li { background: var(--bg); border: 1px solid var(--line); }
.field input, .field select { border-color: var(--field-line); background: var(--bg); }
.card.st-taken, .card.st-late { background: var(--ok-bg); border-color: var(--ok-line); }
.card.st-notyet { background: var(--no-bg); border-color: var(--no-line); }
.card.st-none { background: var(--wait-bg); border-color: var(--wait-line); }
.card.st-none.st-evening { background: var(--eve-bg); border-color: var(--eve-line); }
.chip { background: var(--bg); }
.chip-taken, .chip-late { border-color: var(--ok-line); color: var(--ok-text); background: var(--bg); }
.chip-notyet { border-color: var(--no-line); color: var(--no-text); }
.chip-none { border-color: var(--wait-line); color: var(--wait-text); }
.banner { background: var(--alert-bg); color: var(--alert-text); border: 2px solid var(--no-line); }
.alert-card { background: var(--alert-bg); color: var(--alert-text); border-color: var(--no-line); }
.alert-card .hint { color: var(--alert-text); }
.alert-card.alert-ok { background: var(--late-bg); color: var(--text); border-color: var(--wait-line); }
.alert-card.alert-ok .hint { color: var(--text); }
.alert-ico { background: var(--bg); }
.hero-card { border: 2px solid var(--ok-line); box-shadow: var(--shadow); }
.tabs { border-top: 2px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: none; }
.tab.is-on { background: var(--accent-soft); color: var(--primary); }
.round-pill { background: var(--wait-bg); color: var(--wait-text); }
.btn-primary, .btn-taken { box-shadow: 0 4px 0 var(--ok-line); }

/* ทางเข้า: หน้าแรก (เนินเขียว + น้องเมล็ดพีช) และเลือกบทบาท ตามแคนวาส */
.entry-body { background: var(--bg-grad-1); }
.splash { position: relative; overflow: hidden; background: var(--bg-grad-1); }
.splash::before { content: ""; position: absolute; left: -20%; right: -20%; bottom: -18%; height: 48%; border-radius: 50%; background: var(--accent-soft); }
.splash > * { position: relative; }
.entry-title { margin: 0; font-size: 44px; font-weight: 700; color: var(--primary); }
.entry-sub { margin: 0; font-family: var(--font-head); font-size: var(--fs-h2); color: var(--text-muted); }
.bubble { display: inline-block; padding: var(--space-1) var(--space-2); border-radius: 20px; background: var(--bg); border: 2px solid var(--line); box-shadow: var(--shadow); color: var(--text); }
.roles .role-card { display: flex; align-items: center; gap: var(--space-2); }
.role-ico { display: flex; align-items: center; justify-content: center; flex: none; width: 64px; height: 64px; border-radius: 22px; }
.role-ico .ico { width: 34px; height: 34px; }
.role-ico.senior { background: var(--accent-soft); color: var(--primary); }
.role-ico.care { background: var(--no-bg); color: var(--no-text); }
.role-text { flex: 1; display: flex; flex-direction: column; }
.role-text strong { font-family: var(--font-head); font-size: var(--fs-h2); }
.role-text span { color: var(--text-muted); }
.role-go .ico { width: 26px; height: 26px; color: var(--primary); }
.roles-head { display: flex; align-items: flex-end; gap: var(--space-1); }
.roles-head h1 { flex: 1; }
.splash-body { gap: var(--space-1); }
.splash .bubble { margin: var(--space-3) 0 0; }
.entry-brand { justify-content: flex-start; margin: 0 0 var(--space-2); }
.roles .role-card { margin-top: var(--space-2); min-height: 0; padding: var(--space-3) var(--space-2); }

/* เพิ่มยาจากฉลาก: ปุ่มถ่ายรูป/เลือกรูปชัดเจน (input file ซ่อนไว้ในปุ่ม) · ขั้นตอนตั้งค่าครั้งแรก */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn-file { position: relative; }
.btn-file:focus-within { outline: 3px solid var(--text); outline-offset: 2px; }
.viewfinder { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); height: 140px; margin-bottom: var(--space-2); border-radius: var(--radius-lg); background: var(--text); color: var(--bg); text-align: center; padding: var(--space-2); }
.viewfinder .ico { width: 56px; height: 56px; }
.viewfinder::before { content: ""; position: absolute; inset: 16px; border: 4px dashed var(--accent-soft); border-radius: var(--radius); }
.step-pill { display: inline-block; padding: 4px var(--space-2); border-radius: 999px; background: var(--wait-bg); color: var(--wait-text); font-weight: bold; }
.meal-times .h-card .ico, .card .h-card .ico { margin-right: var(--space-1); }
.meal-times .card-head .btn { width: auto; min-height: var(--tap-min); }
/* ข้อความแจ้ง (toast) อยู่ใต้แถบหัว ไม่บังปุ่มด้านล่าง — ค้าง 10 วินาทีตาม WCAG แต่ต้องกดปุ่มล่างได้เสมอ */
.toast-region { top: 64px; bottom: auto; }
body.real .toast-region { top: calc(64px + env(safe-area-inset-top)); }

/* Site ทดสอบ: เผื่อพื้นที่สระ/วรรณยุกต์ไทยและหัวข้อหลายบรรทัด */
.phone { font-family: var(--font); line-height: 1.65; }
.appbar, .covers, .tabs, .role-navigation { flex-shrink: 0; }
.screen { min-height: 0; }
h1, h2, h3, .h-card, .hero-big, .appbar-title, .brand, .entry-title { line-height: 1.55; }
.hero-label { line-height: 1.65; margin-bottom: 4px; }
.hero-big { margin-bottom: var(--space-1); }
.hero-sub { line-height: 1.65; }
.card-head { flex-wrap: wrap; align-items: center; row-gap: var(--space-1); }
.card-head > .h-card { flex: 1 1 140px; min-width: 0; font-variant-numeric: tabular-nums; }
.card-head > .chip { flex: 0 1 auto; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.chip, .hero-chip, .role-chip, .count { line-height: 1.65; padding-top: 2px; padding-bottom: 2px; }
.sec-head { flex-wrap: wrap; gap: var(--space-1); }
.med-name { line-height: 1.55; }
.meds li { row-gap: 4px; }
.ring span { line-height: 1.5; }
.appbar { flex-wrap: wrap; }
.appbar-title { min-width: 0; }
.tab-label { line-height: 1.5; }
[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
.language-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1) var(--space-2); color: var(--text); background: var(--bg); border-bottom: 1px solid var(--line); flex-shrink: 0; font-size: 18px; }
.language-controls > span { margin-right: auto; }
.language-controls button { min-height: 48px; padding: 4px var(--space-2); border: 2px solid var(--primary); border-radius: var(--radius); background: var(--bg); color: var(--primary); cursor: pointer; font-size: 18px; font-weight: 600; }
.language-controls button[aria-pressed="true"] { background: var(--primary); color: var(--on-color); }
.language-controls button:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
#page-language { max-width: 880px; margin: 0 auto var(--space-1); }
.tab { min-width: 0; }
.tab-label { max-width: 100%; white-space: nowrap; overflow-wrap: normal; word-break: normal; hyphens: none; }

/* Five caregiver tabs use one equal, compact label size without splitting Thai or English words.
 * Keep the older adult's three-tab typography and all medicine/body text unchanged. */
.tabs-caregiver { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; }
.tabs-caregiver .tab { width: 100%; min-width: 0; min-height: 64px; padding: 6px 2px; }
.tabs-caregiver .tab-label { font-size: clamp(12px, 3.4vw, 14px); line-height: 1.5; white-space: nowrap; overflow-wrap: normal; word-break: normal; hyphens: none; }
.tabs-caregiver .tab .ico { width: 26px; height: 26px; }

/* Native time controls, especially in embedded mobile browsers, must shrink to the card width. */
.field { min-width: 0; max-width: 100%; }
.field input, .field select { min-width: 0; max-width: 100%; }
.field input[type="time"] { display: block; box-sizing: border-box; min-inline-size: 0; inline-size: 100%; max-inline-size: 100%; }
.field input[type="time"]::-webkit-date-and-time-value { min-width: 0; text-align: left; }
.field input[type="time"]::-webkit-datetime-edit { min-width: 0; }

/* WebKit iOS native date/time styling forces content-box after author styles
 * (WebKit issue 301648). Remove that appearance only for meal-time controls
 * on iOS; retain type=time, the picker, values, events, and Android styling. */
@supports (-webkit-touch-callout: none) {
  .field input[type="time"][data-time] {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    min-width: 0;
    min-inline-size: 0;
    width: 100%;
    inline-size: 100%;
    max-width: 100%;
    max-inline-size: 100%;
  }
}

/* Unpaired navigation and language controls inside settings remain ordinary touch targets. */
.role-navigation { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1); padding-top: var(--space-1); padding-bottom: var(--space-1); }
.role-navigation .btn { flex: 0 1 auto; width: auto; max-width: 100%; min-height: max(48px, var(--tap-min)); margin: 0; }
.card .language-controls { justify-content: flex-start; padding: 0; margin-top: var(--space-1); border-bottom: 0; background: transparent; }
.card .language-controls > span { flex: 1 1 100%; margin: 0; }
.settings-language .language-controls > span { display: none; }
.card .language-controls button { flex: 0 0 auto; width: auto; min-height: max(48px, var(--tap-min)); margin: 0; }

/* Entry-page settings stay compact; language choices expand inside the same details element. */
.entry-preferences { max-width: 480px; margin: 0 auto; padding: var(--space-1) var(--space-3) 0; color: var(--text); }
.entry-preferences > summary { display: flex; align-items: center; justify-content: center; gap: var(--space-1); width: fit-content; max-width: 100%; min-height: 48px; margin-left: auto; padding: var(--space-1) var(--space-2); border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--bg); color: var(--primary); cursor: pointer; font-weight: 600; list-style: none; }
.entry-preferences > summary::-webkit-details-marker { display: none; }
.entry-preferences > summary::after { content: '▾'; }
.entry-preferences[open] > summary::after { transform: rotate(180deg); }
.entry-preferences > summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.entry-preferences #page-language { max-width: none; margin: var(--space-1) 0 0; }
.entry-preferences .language-controls { justify-content: flex-start; padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius); }

/* ผล OCR สำรองจากระบบสแกนล่าสุด (FR-02) */
.ocr-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; max-height: 12em; overflow-y: auto; padding: var(--space-2); background: var(--bg); border-radius: var(--radius); }
