:root {
  --green: #58cc02;
  --green-dark: #58a700;
  --green-light: #d7ffb8;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --orange: #ff9600;
  --orange-dark: #e08600;
  --purple: #ce82ff;
  --purple-dark: #a568cc;
  --pink: #ff86d0;
  --pink-dark: #e070b5;
  --gold: #ffc800;
  --ink: #3c3c3c;
  --muted: #777;
  --line: #e5e5e5;
  --bg: #fff;
  --card: #fff;
  --soft2: #f0f0f0;
  --line2: #cfcfcf;
  --faint: #9a9a9a;
  --blue-soft: #ddf4ff; --blue-soft2: #f5fbff; --blue-line: #84d8ff;
  --green-soft: #f1ffe6; --green-line: #b8f28b;
  --red-soft: #ffdfe0; --red-line: #ffc1c1;
  --orange-soft: #fff0d5; --purple-soft: #f3e1ff; --pink-soft: #ffe3f4;
  --yellow-soft: #fff8dc; --yellow-line: #ffe08a; --yellow-ink: #9a7300;
  --soft: #f7f7f7;
}
/* ---------- Mod gelap (lalai) ---------- */
html.dark {
  color-scheme: dark;
  /* Hampir hitam + kad kelabu neutral (ikut contoh pengguna) */
  --bg: #08080a; --card: #141318; --soft: #1c1b22; --soft2: #24232b;
  --line: #26252e; --line2: #403f4f; --ink: #f4f4f6; --muted: #a8a8b3; --faint: #72717e;
  --green-light: #1f3315; --blue-dark: #5aa9ff;
  --blue-soft: #344153; --blue-soft2: #121a24; --blue-line: #3d5f86;
  --green-soft: #15220e; --green-line: #3c6b1f;
  --red-soft: #60313c; --red-line: #7a3a48;
  --orange-soft: #3a2a12; --purple-soft: #3a2d55; --pink-soft: #4a2440;
  --yellow-soft: #2b1d0d; --yellow-line: #f0b95c; --yellow-ink: #f2c94c;
}
html.dark body { background: var(--bg); }
html.dark .overlay { background: rgba(0, 0, 0, .7); }
html.dark .day .dot { background: #2e2e3c; }
html.dark .progress { background: #2c2c37; }
html.dark .check:not(.on):not(.skip) { border-color: var(--line2); box-shadow: 0 3px 0 var(--line); }
html.dark .skip-btn { border-color: var(--yellow-line); }
html.dark ::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, .18); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100%;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.4;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { margin: 0; font-weight: 800; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.page { padding: 20px 16px 110px; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.page.full { padding-bottom: 24px; }

/* ---------- Butang ala "chunky" ---------- */
.btn {
  --c: var(--green); --cd: var(--green-dark); --t: #fff;
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 16px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--t); background: var(--c);
  border-radius: 16px; padding: 14px 18px; width: 100%;
  box-shadow: 0 4px 0 var(--cd);
  transition: transform .06s, box-shadow .06s, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { filter: brightness(.9); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--cd); }
.btn:disabled, .btn.blue:disabled, .btn.red:disabled, .btn.ghost:disabled { --c: #e5e5e5; --cd: #ccc; --t: var(--faint); cursor: default; }
.btn.blue { --c: var(--blue); --cd: var(--blue-dark); }
.btn.red { --c: var(--red); --cd: var(--red-dark); }
.btn.ghost { --c: var(--card); --cd: var(--line); --t: var(--blue); border: 2px solid var(--line); }
.btn.ghost.danger { --t: var(--red); }
.btn.small { width: auto; padding: 10px 14px; font-size: 14px; border-radius: 14px; }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 20px; letter-spacing: 0; }

.link { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 800; cursor: pointer; padding: 6px; text-transform: uppercase; font-size: 14px; letter-spacing: .6px; }

/* ---------- Kad ---------- */
.card {
  border: 2px solid var(--line); border-radius: 18px; padding: 16px;
  background: var(--card); box-shadow: 0 4px 0 var(--line);
}
.card.tap { cursor: pointer; transition: transform .06s, box-shadow .06s; }
.card.tap:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }

/* ---------- Borang ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 15px; }
input, select, textarea {
  font: inherit; font-weight: 600; color: var(--ink);
  background: var(--soft); border: 2px solid var(--line); border-radius: 14px;
  padding: 13px 14px; width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); background: var(--card); }
textarea { resize: vertical; min-height: 70px; }
.error { background: var(--red-soft); color: var(--red-dark); border-radius: 14px; padding: 12px 14px; font-weight: 700; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 2px solid var(--line);
}
.topbar .title { flex: 1; font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .title span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { background: none; border: 0; font-size: 26px; color: var(--faint); cursor: pointer; padding: 0 6px; font-weight: 800; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 17px; padding: 4px 10px; border-radius: 12px; }
.pill.fire { color: var(--orange); }
.pill.fire.off { color: var(--faint); filter: grayscale(1); }

/* ---------- Tab bawah ---------- */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; background: var(--bg); border-top: 2px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tabs button {
  flex: 1; background: none; border: 2px solid transparent; border-radius: 14px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; margin: 0 4px;
}
.tabs button .ic { font-size: 26px; filter: grayscale(1) opacity(.55); }
.tabs button { position: relative; z-index: 1; transition: color .35s ease-in-out; }
.tabs button.on { color: var(--blue); }
.tabs .ic { transition: filter .35s ease-in-out; }
.seg-pill.tab-pill { background: var(--blue-soft); border: 2px solid var(--blue-line); box-shadow: none; border-radius: 14px; box-sizing: border-box; }
.tabs button.on .ic { filter: none; }

/* ---------- Welcome ---------- */
.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 30px 8px; }
.hero h1 { font-size: 34px; color: var(--green); }
.hero p { font-size: 19px; font-weight: 700; color: var(--muted); max-width: 320px; }
.mascot { width: 170px; height: 170px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }

/* ---------- Senarai keluarga ---------- */
.elder { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 34px;
  background: var(--green-light); flex-shrink: 0;
}
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--line) 0); }
.ring > div { width: 50px; height: 50px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: 14px; }

/* ---------- Hari ini ---------- */
.progress { height: 18px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 99px; position: relative; transition: width .6s ease-in-out, min-width .6s ease-in-out; min-width: 18px; }
.progress > div::after { content: ''; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.35); }
.progress.zero > div { min-width: 0; }

.week { display: flex; justify-content: space-between; gap: 6px; }
.day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: var(--faint); }
.day .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: 16px; color: #fff; }
.day.full .dot { background: var(--orange); }
.day.part .dot { background: var(--yellow-line); }
.day.today { color: var(--ink); }
.day.today .dot { outline: 3px solid var(--yellow-line); outline-offset: 2px; }

.slot-title { font-weight: 800; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.dose { display: flex; align-items: center; gap: 14px; }
.pillicon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; flex-shrink: 0; }
.dose .name { font-weight: 800; font-size: 18px; }
.dose .sub { color: var(--muted); font-weight: 700; font-size: 14px; }
.dose.done { background: var(--green-soft); border-color: var(--green-line); box-shadow: 0 4px 0 var(--green-line); }
.dose.done .name { color: var(--green-dark); }
.dose.skipped { background: var(--soft); }
.dose.skipped .name { color: var(--faint); }
.dose.late:not(.done) { border-color: var(--red-line); box-shadow: 0 4px 0 var(--red-line); }
.check {
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--line); background: var(--card);
  font-size: 26px; cursor: pointer; display: grid; place-items: center; color: transparent; flex-shrink: 0;
  box-shadow: 0 3px 0 var(--line); transition: transform .08s;
}
.check:active { transform: scale(.9); }
/* Butang skip kecil (kotak) sebelum butang tick */
.skip-btn { flex-shrink: 0; align-self: center; border: 2px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 12px; padding: 7px 10px; font: inherit; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .4px;
  cursor: pointer; box-shadow: 0 2px 0 var(--line); transition: transform .06s, box-shadow .06s; }
.skip-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--line); }
/* Skip: kuning pudar */
.skip-btn { background: var(--yellow-soft); border-color: var(--yellow-line); color: var(--yellow-ink); box-shadow: 0 2px 0 var(--yellow-line); }
.skip-btn:active { box-shadow: 0 0 0 var(--yellow-line); }
.check.on { background: var(--green); border-color: var(--green-dark); color: #fff; box-shadow: 0 3px 0 var(--green-dark); }
.check.skip { background: var(--soft2); border-color: var(--line2); color: var(--faint); box-shadow: 0 3px 0 var(--line2); font-size: 20px; }
.check.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.25); } }

/* warna ubat */
.c-green { background: var(--green-light); }
.c-blue { background: var(--blue-soft); }
.c-red { background: var(--red-soft); }
.c-orange { background: var(--orange-soft); }
.c-purple { background: var(--purple-soft); }
.c-pink { background: var(--pink-soft); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 42px; height: 42px; border-radius: 12px; border: 3px solid transparent; cursor: pointer; font-size: 20px; display: grid; place-items: center; }
.swatch.on { border-color: var(--blue); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--blue-soft); color: var(--blue-dark); font-weight: 800; border-radius: 12px; padding: 8px 10px; }
.chip button { background: none; border: 0; color: var(--blue-dark); font-size: 18px; cursor: pointer; padding: 0 2px; line-height: 1; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.presets button { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 7px 10px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 2px 0 var(--line); }

/* ---------- Keluarga ---------- */
.code-box { text-align: center; background: var(--blue-soft); border: 2px solid var(--blue-line); box-shadow: 0 4px 0 var(--blue-line); }
.code { font-size: 40px; font-weight: 900; letter-spacing: 8px; color: var(--blue-dark); margin: 6px 0 12px; }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--soft); }
.member:last-child { border-bottom: 0; }
.member .avatar { width: 46px; height: 46px; font-size: 20px; font-weight: 800; color: #fff; }
.badge { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 3px 8px; border-radius: 8px; background: var(--orange-soft); color: var(--orange-dark); }
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 15px; }
.feed-item b { font-weight: 800; }

/* ---------- Kosong ---------- */
.empty { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .big { font-size: 64px; }

/* ---------- Modal / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0; padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; animation: up .25s cubic-bezier(.2,1,.3,1); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40%); } }

/* ---------- Sambutan ---------- */
.celebrate { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; animation: fade .25s; }
.celebrate .big { font-size: 96px; animation: pop .6s; }
.celebrate h1 { color: var(--orange); font-size: 32px; }
.celebrate.closing { animation: fadeOut .3s ease forwards; pointer-events: none; }
@keyframes fadeOut { to { opacity: 0; } }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; border-radius: 3px; z-index: 61; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800; z-index: 70; animation: fade .2s; max-width: 90vw; text-align: center; }

.spinner { margin: 60px auto; width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Utiliti ---------- */
.small { font-size: 14px; }
.bold { font-weight: 800; }
.tiny-p { font-size: 12px; margin-top: 6px; }
.ok { color: var(--green-dark); }
.sub.ok { color: var(--green-dark); }
.sub.bad { color: var(--red); }
.sub.due { color: var(--orange-dark); }
.sub.skip { color: var(--faint); }
.chev { color: var(--faint); font-size: 22px; }
.link.tiny { font-size: 12px; padding: 4px 0 0; color: var(--faint); text-transform: none; letter-spacing: 0; }
.icon-btn { background: none; border: 0; font-size: 22px; cursor: pointer; padding: 4px 6px; border-radius: 12px; }
.icon-btn:hover { background: var(--soft); }
.icon-btn.big { font-size: 32px; background: var(--blue-soft); width: 60px; height: 60px; border-radius: 50%; }
.row.two { align-items: stretch; }
.row.two > * { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note { background: var(--yellow-soft); color: var(--yellow-ink); border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: 15px; }
.banner { display: flex; gap: 12px; align-items: center; padding: 14px; background: var(--yellow-soft); border-color: var(--yellow-line); box-shadow: 0 4px 0 var(--yellow-line); }
.banner.blue-soft { display: block; background: var(--blue-soft); border-color: var(--blue-line); box-shadow: 0 4px 0 var(--blue-line); }
.code-input { font-size: 28px; text-align: center; letter-spacing: 6px; text-transform: uppercase; font-weight: 900; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Kawalan bersegmen */
.seg { display: flex; background: var(--soft); border: 2px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 9px 6px; font: inherit; font-weight: 800; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg { position: relative; }
.seg button { position: relative; z-index: 1; transition: color .35s ease-in-out; }
.seg button.on { color: var(--blue-dark); }
/* Penanda putih yang meluncur (diletakkan oleh JS) */
.seg-pill { position: absolute; top: 0; left: 0; width: 0; height: 0; opacity: 0; z-index: 0; pointer-events: none;
  background: var(--card); border-radius: 10px; box-shadow: 0 2px 0 var(--line);
  transition: transform .35s ease-in-out, width .35s ease-in-out, height .35s ease-in-out; }
.field > .seg, .field > #daysBox, .field > .chips, .field > .presets, .field > .swatches { margin-top: 6px; }
div.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 15px; }

/* Pilih hari / tarikh */
.daypick { display: grid; gap: 6px; margin-top: 4px; }
.daypick.weekly { grid-template-columns: repeat(7, 1fr); }
.daypick.monthly { grid-template-columns: repeat(7, 1fr); }
.daypick button { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 0; font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; box-shadow: 0 2px 0 var(--line); color: var(--ink); }
.daypick button.on { background: var(--blue); border-color: var(--blue-dark); color: #fff; box-shadow: 0 2px 0 var(--blue-dark); }

/* Input nombor dengan unit */
.field.num input { padding-right: 10px; }
.unit-wrap { position: relative; display: block; }
.unit-wrap input { padding-right: 62px; }
.unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; font-weight: 700; pointer-events: none; }
.unit.static { position: static; transform: none; }
input.scanned { background: var(--yellow-soft); border-color: #ffc800; }

/* Sebab skip */
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason { position: relative; }
.reason input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.reason span { display: block; border: 2px solid var(--line); border-radius: 14px; padding: 12px; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.reason input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); box-shadow: 0 3px 0 var(--blue-line); }
.reason input:focus-visible + span { outline: 3px solid var(--blue); }
.big-text, .big-text .reason span { font-size: 20px; }

/* Tetapan */
.setting { border-top: 2px solid var(--soft); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.setting-label { font-weight: 800; }

/* Checkup */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.tile { border: 2px solid var(--line); border-radius: 16px; padding: 10px 12px; background: var(--card); }
.tile .tl { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tile .tv { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.tile .tv small { font-size: 12px; color: var(--muted); font-weight: 700; }
.tile.high { border-color: var(--red-line); background: var(--red-soft); }
.tile.high .tv { color: var(--red-dark); }
.trend { font-size: 16px; color: var(--muted); }
.minis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mini { background: var(--soft); border-radius: 10px; padding: 4px 8px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mini.high { background: var(--red-soft); color: var(--red-dark); }
.card.report { background: var(--blue-soft2); border-color: var(--blue-line); box-shadow: 0 4px 0 var(--blue-line); }

/* Peringatan (alarm) dalam app */
.alarm { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.alarm-card { background: var(--card); border-radius: 24px; padding: 24px; text-align: center; max-width: 380px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.alarm-bell { font-size: 72px; animation: ring 1s ease-in-out 3; }
.alarm.elder .alarm-card h2 { font-size: 30px; }
.alarm.elder .alarm-card p { font-size: 24px; }
@keyframes ring { 20%, 60% { transform: rotate(-18deg); } 40%, 80% { transform: rotate(18deg); } }
.big-p { font-weight: 700; font-size: 18px; }

/* ---------- MOD ORANG TUA ---------- */
.btn.huge { font-size: 24px; padding: 22px 18px; border-radius: 20px; box-shadow: 0 6px 0 var(--cd); letter-spacing: .5px; }
.btn.huge:active { transform: translateY(6px); }
.elder-mode { padding: 20px 16px 30px; display: flex; flex-direction: column; gap: 18px; font-size: 20px; min-height: 100vh; min-height: 100dvh; }
.ehead { display: flex; align-items: center; gap: 12px; }
.eemoji { font-size: 52px; width: 76px; height: 76px; border-radius: 50%; background: var(--green-light); display: grid; place-items: center; flex-shrink: 0; }
.egreet { font-size: 26px; font-weight: 900; line-height: 1.2; }
.edate { color: var(--muted); font-weight: 700; font-size: 17px; }
.ebox { border: 3px solid var(--line); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 5px 0 var(--line); }
.ebox.calm, .ebox.done { align-items: center; text-align: center; }
.ebox.done { background: var(--green-soft); border-color: var(--green-line); box-shadow: 0 5px 0 var(--green-line); }
.ebox .mascot { width: 120px; height: 120px; }
.etitle { font-size: 26px; font-weight: 900; }
.etitle.sm { font-size: 20px; color: var(--muted); margin-bottom: 4px; }
.ecard { background: var(--soft); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pillicon.big { width: 76px; height: 76px; font-size: 42px; border-radius: 20px; }
.ename { font-size: 28px; font-weight: 900; line-height: 1.15; }
.esub { font-size: 19px; color: var(--muted); font-weight: 700; }
.elink { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--muted); }
.etoday { border-top: 2px solid var(--line); padding-top: 14px; }
.erow { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-weight: 800; font-size: 20px; border-bottom: 2px solid var(--soft); }
.erow.is-done { color: var(--faint); }
.etime { min-width: 120px; color: var(--muted); font-size: 17px; }
.estat { font-size: 24px; }
.hold { margin-top: auto; position: relative; overflow: hidden; border: 2px dashed var(--line2); background: var(--card); border-radius: 16px; padding: 14px; font: inherit; font-size: 15px; font-weight: 800; color: var(--faint); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.hold-fill { position: absolute; inset: 0; width: 0; background: var(--blue-soft); }
.hold.holding .hold-fill { width: 100%; transition: width 2s linear; }
.hold-text { position: relative; }

@media (max-width: 360px) {
  .grid2, .reasons { grid-template-columns: 1fr; }
  .tabs button { font-size: 11px; }
}

/* ---------- Scrollbar: nipis, pudar, dalam kotak, tiada latar gelap ---------- */
/* Firefox guna sifat standard; Chrome/Safari guna ::-webkit-scrollbar (tanpa anak panah) */
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: rgba(60, 60, 60, .2) transparent; } }
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
::-webkit-scrollbar-thumb { background-color: rgba(60, 60, 60, .2); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(60, 60, 60, .35); }
/* Bar skrol sheet duduk di dalam bucu bulat kotak */
.sheet { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.sheet::-webkit-scrollbar-track { margin: 22px 0; }

/* ---------- Peralihan skrin (swipe) ---------- */
#app { overflow-x: clip; }
.swipe-layer { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
/* Skrin lama: mengecil sedikit dan pudar sampai hilang */
.swipe-ghost { position: absolute; margin: 0; background: var(--bg); box-sizing: border-box; animation: shrinkFade .42s ease-out forwards; }
/* Skrin baru: meluncur masuk di atas skrin lama */
.in-right, .in-left { position: relative; z-index: 6; background: var(--bg); }
.in-right { box-shadow: -10px 0 24px rgba(0,0,0,.08); animation: slideInRight .42s cubic-bezier(.2, .8, .2, 1); }
.in-left { box-shadow: 10px 0 24px rgba(0,0,0,.08); animation: slideInLeft .42s cubic-bezier(.2, .8, .2, 1); }
@keyframes shrinkFade { to { transform: scale(.92); opacity: 0; } }
@keyframes slideInRight { from { transform: translateX(100%); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } }
@keyframes deskOut { to { opacity: 0; } }
@keyframes deskInRight { from { opacity: 0; transform: translateX(16px); } }
@keyframes deskInLeft { from { opacity: 0; transform: translateX(-16px); } }

/* Butang sentiasa guna warna tulisan app (bukan warna tema gelap browser) */
button { color: var(--ink); }
.presets button:disabled { background: var(--soft2); color: var(--faint); border-color: var(--line2); box-shadow: none; cursor: default; }
.other-time { margin-top: 4px; }
.overlay.closing { animation: fadeOut .28s ease forwards; pointer-events: none; }
/* Helaian ditutup: turun ke bawah sambil pudar; popup tengah mengecil sedikit */
.overlay.closing .sheet { animation: sheetDown .28s cubic-bezier(.4, 0, .9, .6) forwards; }
.overlay.popup.closing .sheet { animation: popOut .22s ease-in forwards; }
@keyframes sheetDown { to { transform: translateY(60%); opacity: 0; } }
@keyframes popOut { to { transform: scale(.94); opacity: 0; } }
/* Pilihan hubungan (Anak, Cucu, ...) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: block; border: 2px solid var(--line); border-radius: 999px; padding: 9px 16px; background: var(--card); color: var(--ink);
  font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 3px 0 var(--line); transition: background .2s, color .2s, border-color .2s; }
.choice input:checked + span { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-dark); box-shadow: 0 3px 0 var(--blue-line); }
.choice input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.alarm.closing { animation: fadeOut .3s ease forwards; pointer-events: none; }

/* ---------- Tab Ubat: butang Edit & Sejarah ---------- */
.med-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.mini-btn { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 7px 10px;
  font: inherit; font-weight: 800; font-size: 13px; cursor: pointer; box-shadow: 0 2px 0 var(--line); white-space: nowrap; transition: transform .06s, box-shadow .06s; }
.mini-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--line); }

/* ---------- Tab Sejarah ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav b { font-size: 18px; text-align: center; }
.nav-btn { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 8px 12px; font: inherit; font-weight: 800; font-size: 14px;
  cursor: pointer; box-shadow: 0 2px 0 var(--line); white-space: nowrap; }
.nav-btn:disabled { opacity: .4; cursor: default; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fchip { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 7px 13px; font: inherit; font-weight: 800; font-size: 14px;
  cursor: pointer; box-shadow: 0 2px 0 var(--line); transition: background .2s, border-color .2s, color .2s; }
.fchip.on { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-dark); box-shadow: 0 2px 0 var(--blue-line); }
.hist-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hist-sum > div { border: 2px solid var(--line); border-radius: 14px; padding: 10px 4px; text-align: center; background: var(--card); }
.hist-sum .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hist-sum .l { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.skipc { color: var(--yellow-ink); }
.hist-day { border: 2px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; }
.hist-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--soft); }
.hist-count { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-count.full { color: var(--orange); }
.hist-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; align-items: center; padding: 9px 14px; border-top: 2px solid var(--soft); font-size: 15px; }
.ht { color: var(--muted); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.hn { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs { font-size: 13px; font-weight: 800; border-radius: 10px; padding: 3px 8px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs.ok { background: var(--green-soft); color: var(--green-dark); }
.hs.skip { background: var(--yellow-soft); color: var(--yellow-ink); }
.hs.bad { background: var(--red-soft); color: var(--red); }
.hs.wait { background: var(--soft); color: var(--muted); }
/* 5 tab: tulisan lebih kecil supaya muat */
.tabs button { font-size: 11px; letter-spacing: .3px; margin: 0 2px; padding: 6px 2px; line-height: 1.15; text-align: center; }

/* ---------- Popup kecil di tengah skrin ---------- */
.overlay.popup { align-items: center; padding: 16px; }
.sheet.dialog { border-radius: 24px; max-width: 400px; padding: 20px 16px; animation: dialogIn .25s cubic-bezier(.2, 1, .3, 1); }
@keyframes dialogIn { from { opacity: 0; transform: scale(.92); } }

/* Tukar bulan dalam Sejarah: nama bulan & log meluncur masuk */
#monthLabel { display: inline-block; }
.slide-from-left { animation: monthInLeft .38s ease-in-out; }
.slide-from-right { animation: monthInRight .38s ease-in-out; }
@keyframes monthInLeft { from { transform: translateX(-40px); opacity: 0; } }
@keyframes monthInRight { from { transform: translateX(40px); opacity: 0; } }

/* Butang ubat (bulat): lantunan kecil bila ditekan */
.fchip.bounce, .nav-btn.bounce { animation: chipBounce .38s ease-out; }
/* Garisan pemisah antara navigasi bulan dan tapisan */
.filter { border-top: 2px solid var(--line); padding-top: 16px; }
.filter-head { align-items: center; }
.filter-head .mini-btn { color: var(--blue-dark); }
@keyframes chipBounce { 0% { transform: scale(1); } 35% { transform: scale(.92); } 70% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* ---------- Check-up: kotak bacaan boleh ditekan, popup senarai bacaan ---------- */
button.tile { font: inherit; text-align: left; color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--line); transition: transform .06s, box-shadow .06s; }
button.tile:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
button.tile.high { box-shadow: 0 3px 0 var(--red-line); }
.rlist { display: flex; flex-direction: column; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; max-height: 50vh; overflow-y: auto; }
.rrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-top: 2px solid var(--soft); }
.rrow:first-child { border-top: 0; }
.rl { font-weight: 700; color: var(--muted); font-size: 14px; }
.rv { font-weight: 900; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rv small { font-size: 12px; color: var(--muted); font-weight: 700; }
.rrow.high .rv { color: var(--red); }
.rrow.high { background: var(--red-soft); }
.back-link { align-self: flex-start; padding: 0; margin-bottom: -10px; }
.link-blue { color: var(--blue-dark); }
.dose.tap .mini-btn { align-self: center; }

/* Input kekal 16px: elak iPhone zoom sendiri bila kotak ditekan */
input, select, textarea { font-size: 16px; }

/* Sejarah: api kelabu untuk hari yang belum lengkap */
.hist-count .fire-ic { filter: grayscale(1); opacity: .45; }
.hist-count.full .fire-ic { filter: none; opacity: 1; }
/* Sejarah: cip ubat lebih kecil, ruang lebih lega */
.filter .chips-row { margin-top: 12px; gap: 6px; }
.filter .fchip { padding: 4px 9px; font-size: 11px; border-width: 1.5px; }
.filter .fchip.on { box-shadow: 0 1.5px 0 var(--blue-line); }
#histLog { margin-top: 6px; }
.hist-sum { margin-bottom: 4px; }
/* Tab bawah: ikon & teks lebih kecil */
.tabs { padding-top: 12px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.tabs button { font-size: 11px; gap: 5px; padding: 10px 2px; }
.tabs button .ic { font-size: 18px; }
/* Check-up: ruang antara butang imbas & bacaan terkini */
.ck-latest { margin-top: 8px; }
/* Ubat lama */
.past-toggle { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 10px; background: none; border: 0; padding: 6px 2px;
  font: inherit; color: inherit; cursor: pointer; text-align: left; }
.past-toggle .caret { color: var(--muted); transition: transform .25s ease-in-out; }
.past-toggle.open .caret { transform: rotate(180deg); }
.past-list { display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden; transition: grid-template-rows .3s ease-in-out, opacity .25s ease-in-out, visibility 0s .3s; }
.past-list.open { grid-template-rows: 1fr; opacity: 1; visibility: visible; transition-delay: 0s; }
.past-inner { overflow: hidden; display: flex; flex-direction: column; gap: 12px; }
.past-list.open .past-inner { padding-bottom: 2px; }
.past-med { opacity: .75; }
.past-med .pillicon { filter: grayscale(.8); }
.past-btns { gap: 6px; align-items: stretch; }
.past-btns .mini-btn { text-align: center; }

/* Sejarah: menu lungsur pilih ubat */
.dd { position: relative; margin-top: 12px; }
.dd-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--card); color: var(--ink); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; text-align: left; }
.dd-btn .caret { color: var(--muted); transition: transform .25s ease-in-out; }
.dd.open .dd-btn { border-color: var(--blue-line); }
.dd.open .dd-btn .caret { transform: rotate(180deg); }
.dd-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--card); border: 2px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); max-height: 300px; overflow-y: auto;
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.dd.open .dd-menu { opacity: 1; transform: none; pointer-events: auto; }
.dd-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.dd-item:hover { background: var(--soft); }
.dd-item input { position: relative; appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; flex: none; cursor: pointer;
  background: #fff; border: 2px solid var(--line2, #cfcfcf); border-radius: 6px; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.dd-item input:checked { background: var(--blue); border-color: var(--blue); }
.dd-item input:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 14px 14px; }
.dd-item.past .grow { color: var(--muted); }
.dd-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: var(--soft); border-radius: 6px; padding: 2px 6px; }
.dd-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* Hover: jadi lebih gelap (bukan lebih cerah) */
@media (hover: hover) {
  .mini-btn:not(:disabled):hover, .nav-btn:not(:disabled):hover, .fchip:hover, .dd-btn:hover, .skip-btn:hover,
  .presets button:not(:disabled):hover, .daypick button:hover, .past-toggle:hover { filter: brightness(.92); }
  .dd-item:hover { background: var(--soft2, var(--soft)); }
}

/* Anak panah dropdown lebih besar */
.caret { display: inline-grid; place-items: center; line-height: 0; }
.caret svg { width: 20px; height: 20px; }
/* Ringkasan sejarah: teks lebih kecil & seragam, ruang lega dalam kotak */
.hist-sum > div { padding: 10px 4px; }
.hist-sum .v { font-size: 19px; }
.hist-sum .l { font-size: 10.5px; letter-spacing: .2px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Pengenalan (3 skrin) ---------- */
.page.intro { gap: 12px; padding-top: 12px; }
.page.intro .stack { gap: 6px; }
.intro-top { justify-content: space-between; }
.muted-link { color: var(--muted); }
.intro-track { flex: 1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -16px; overscroll-behavior-x: contain; }
.intro-track::-webkit-scrollbar { display: none; }
.intro-slide { flex: 0 0 100%; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 10px 28px; box-sizing: border-box; }
.intro-slide h1 { font-size: 28px; }
.intro-slide p { font-size: 17px; font-weight: 700; color: var(--muted); max-width: 320px; line-height: 1.45; }
.illus { position: relative; width: 196px; height: 196px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px; }
.illus.tone-green { background: var(--green-light, #d7ffb8); }
.illus.tone-blue { background: var(--blue-soft); }
.illus.tone-orange { background: var(--orange-soft, #fff1dc); }
.illus-big { font-size: 86px; line-height: 1; }
.illus-big .mascot { width: 136px; height: 136px; }
.illus-chip { position: absolute; width: 58px; height: 58px; border-radius: 18px; background: var(--card); display: grid; place-items: center;
  font-size: 30px; box-shadow: 0 4px 0 var(--line); border: 2px solid var(--line); animation: bob 2.8s ease-in-out infinite; }
.illus-chip.c1 { top: 8px; right: -6px; }
.illus-chip.c2 { bottom: 12px; left: -8px; animation-delay: -1.4s; }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 9px; height: 9px; border-radius: 99px; background: var(--line2, #d6d6d6); cursor: pointer; transition: width .3s ease-in-out, background .3s ease-in-out; }
.dots span.on { width: 26px; background: var(--green); }
/* ---------- Pilih siapa ---------- */
.page.who { gap: 22px; }
.who-opts { gap: 14px; }
.who-opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; padding: 18px 16px; }
.who-opt b { display: block; font-size: 18px; margin-bottom: 2px; }
.who-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--soft); display: grid; place-items: center; font-size: 30px; flex: none; }
.who-opt .radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line2, #d6d6d6); flex: none; transition: border .2s, background .2s; }
.who-opt.on { border-color: var(--blue-line); background: var(--blue-soft); box-shadow: 0 4px 0 var(--blue-line); }
.who-opt.on .who-ic { background: var(--card); }
.who-opt.on .radio { border: 7px solid var(--blue); background: #fff; }

/* ---------- Peranan & privasi ---------- */
.badge.patient { background: var(--green-light, #d7ffb8); color: var(--green-dark, #58a700); }
.badge.carer { background: var(--soft); color: var(--muted); }
.badge.viewer { background: var(--soft); color: var(--faint); }
.view-note { display: flex; align-items: center; gap: 8px; }
.toggle-row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.toggle-row b { display: block; }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--line2, #d6d6d6);
  position: relative; flex: none; cursor: pointer; transition: background .25s ease-in-out; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s ease-in-out; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.center-text { text-align: center; align-items: center; }
.role-opts { gap: 8px; margin-top: 6px; }
.role-opt { display: flex; align-items: center; gap: 12px; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; font-weight: 400; }
.role-opt b { display: block; }
.role-opt input { width: 20px; height: 20px; accent-color: var(--blue); margin: 0; flex: none; }
.role-opt:has(input:checked) { border-color: var(--blue-line); background: var(--blue-soft); }
.simple-opt { display: none; border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.simple-opt.show { display: flex; animation: fadeIn .3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Tutorial pertama kali ---------- */
.tour { position: fixed; inset: 0; z-index: 100; opacity: 0; transition: opacity .25s ease; }
.tour.on { opacity: 1; }
.tour-hole { position: fixed; border-radius: 18px; box-shadow: 0 0 0 9999px rgba(10, 14, 18, .62); pointer-events: none;
  transition: left .35s ease-in-out, top .35s ease-in-out, width .35s ease-in-out, height .35s ease-in-out; outline: 3px solid rgba(255, 255, 255, .9); }
.tour-hole.none { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; outline: 0; }
.tour-tip { position: fixed; left: 16px; right: 16px; max-width: 420px; margin: 0 auto; background: var(--card); color: var(--ink);
  border-radius: 20px; padding: 18px 18px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); transition: top .35s ease-in-out, bottom .35s ease-in-out; }
.tour-tip.centered { top: 50%; transform: translateY(-50%); }
.tour-tip.in { animation: tourIn .3s ease-out; }
.tour-tip.centered.in { animation: none; }
.tour-tip.away { opacity: 0; transition: opacity .15s ease; }
/* Langkah tab: tiada gelap / sorotan, anak panah ke ikon tab */
.tour.nodim .tour-hole { opacity: 0; }
.tour.nodim .tour-tip { box-shadow: 0 10px 34px rgba(0, 0, 0, .22), 0 0 0 2px var(--green); }
.tour.nodim .tour-tip::after { content: ""; position: absolute; left: var(--ax, 50%); bottom: -9px; width: 16px; height: 16px; background: var(--card);
  transform: translateX(-50%) rotate(45deg); box-shadow: 2px 2px 0 0 var(--green); border-radius: 0 0 4px 0; }
.tour-hole { transition: left .35s ease-in-out, top .35s ease-in-out, width .35s ease-in-out, height .35s ease-in-out, opacity .2s; }
@keyframes tourIn { from { opacity: 0; transform: translateY(8px); } }
.tour-title { font-size: 20px; margin: 6px 0 4px; }
.tour-body { color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.45; margin: 0 0 12px; }
.tour-dots { display: flex; gap: 6px; }
.tour-dots span { width: 7px; height: 7px; border-radius: 99px; background: var(--line2, #d6d6d6); transition: width .3s ease-in-out, background .3s; }
.tour-dots span.on { width: 20px; background: var(--green); }
.tour-btns { align-items: center; }

.or-line { display: flex; align-items: center; gap: 12px; color: var(--faint); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 2px; background: var(--line); }
.home-who { gap: 14px; }

/* ---------- Tukar profil, Google, tetamu ---------- */
.topbar .profile-switch { background: none; border: 0; padding: 4px 6px 4px 0; cursor: pointer; font: inherit; color: inherit; text-align: left; border-radius: 12px; }
.topbar .profile-switch .pcaret { flex: none; color: var(--muted); }
.profile-list { gap: 10px; }
.profile-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; padding: 12px 14px; }
.profile-row b { display: block; font-size: 17px; }
.profile-row .avatar { width: 46px; height: 46px; font-size: 26px; }
.profile-row.on { border-color: var(--green-line, #b5f08a); background: var(--green-light, #d7ffb8); }
.pcheck { color: var(--green-dark, #58a700); font-weight: 900; font-size: 20px; }
.gbox { display: flex; justify-content: center; min-height: 44px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; text-transform: none; letter-spacing: 0; --t: var(--ink); }
.gbtn .glogo { flex: none; }
.later-box { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.guest-note { font-size: 14px; }

/* Bar tab: penanda bergerak lebih laju */
.seg-pill.tab-pill { transition-duration: .2s, .2s, .2s; transition-timing-function: cubic-bezier(.3, .7, .3, 1); }
.tabs button, .tabs .ic { transition-duration: .2s; }

/* ---------- Perjanjian pengguna ---------- */
.page.consent { gap: 16px; }
.agree-list { display: flex; flex-direction: column; gap: 12px; }
.agree-list section { background: var(--soft); border-radius: 14px; padding: 12px 14px; }
.agree-list h3 { font-size: 15px; margin: 0 0 4px; }
.agree-list p { margin: 0; color: var(--muted); font-weight: 600; font-size: 14px; line-height: 1.45; }
.agree-check { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; font-size: 15px; line-height: 1.4; cursor: pointer; }
.agree-check input { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border-radius: 7px; cursor: pointer;
  border: 2px solid var(--line2, #cfcfcf); background: #fff; transition: background .15s, border-color .15s; }
.agree-check input:checked { background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 16px no-repeat; border-color: var(--blue); }
.account-links { margin-top: 4px; }
.agree-links { text-align: center; font-weight: 800; }
.agree-links a { color: var(--blue-dark); }
.danger-link { color: var(--red); }

/* ================= Susun atur: pembalut (telefon = tiada kesan) ================= */
.today-grid, .today-side, .today-main, .med-grid, .fam-grid, .fam-col { display: contents; }
.nav-brand { display: none; }

/* ================= DESKTOP (skrin lebar) ================= */
@media (min-width: 900px) {
  body { background: var(--soft); }
  /* Skrin awal (pengenalan, log masuk, perjanjian, setup): kad di tengah */
  #app:not(.with-nav) { max-width: 480px; margin: 40px auto; min-height: 0; background: var(--bg); border-radius: 28px;
    box-shadow: 0 20px 60px rgba(20, 30, 20, .10); overflow: hidden; border: 2px solid var(--line); }
  #app:not(.with-nav) .page.full { min-height: 0; }
  #app:not(.with-nav) .page.intro { min-height: 720px; }
  #app:not(.with-nav) .topbar { position: static; }

  /* Skrin profil: menu tepi di kiri, kandungan lebar */
  #app.with-nav { max-width: none; margin: 0; padding-left: 248px; background: var(--bg); min-height: 100vh; }
  #app.with-nav > .topbar, #app.with-nav > .page { width: 100%; max-width: 1080px; margin: 0 auto; box-sizing: border-box; }
  #app.with-nav > .topbar { padding: 16px 32px; border-bottom: 0; background: var(--bg); }
  #app.with-nav > .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); }
  #app.with-nav > .page { padding: 28px 32px 56px; gap: 22px; }
  #app.with-nav h1 { font-size: 32px; }

  .tabs { top: 0; bottom: 0; left: 0; transform: none; width: 248px; max-width: none; flex-direction: column; justify-content: flex-start;
    gap: 6px; padding: 22px 16px; border-top: 0; border-right: 2px solid var(--line); box-sizing: border-box; }
  .tabs .nav-brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 900; color: var(--green); padding: 4px 10px 22px; letter-spacing: -.3px; }
  .tabs .nav-logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--green-light, #d7ffb8); font-size: 22px; }
  .tabs button { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; margin: 0; padding: 12px 14px;
    font-size: 15px !important; letter-spacing: .4px; text-align: left; }
  .tabs button .ic { font-size: 24px !important; }
  .page { padding-bottom: 56px; }

  /* Hari ini: ringkasan di kiri (melekat), senarai dos di kanan */
  .today-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 28px; align-items: start; }
  .today-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 96px; }
  .today-main { display: flex; flex-direction: column; gap: 14px; }
  .today-main .slot-title:first-child { margin-top: 0; }

  /* Ubat: kad dalam dua lajur */
  .med-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .past-inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

  /* Keluarga: kod & privasi di kiri, ahli & aktiviti di kanan */
  .fam-grid { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 24px; align-items: start; }
  .fam-col { display: flex; flex-direction: column; gap: 18px; }

  /* Sejarah & check-up: lebih lega */
  .page-sejarah { max-width: 880px !important; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)) !important; }

  /* Helaian: popup di tengah, bukan dari bawah */
  .overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 26px; padding: 26px 26px 24px; max-height: 86vh; }
  .toast { bottom: 40px; }

  /* Peralihan tab: skrin lebar tak sesuai meluncur jauh. Guna pudar lembut dengan gerakan kecil. */
  .swipe-ghost { animation: deskOut .12s ease-out forwards; transform-origin: 50% 0 !important; }
  .in-right, .in-left { box-shadow: none; }
  .in-right { animation: deskInRight .24s cubic-bezier(.2, .7, .2, 1); }
  .in-left { animation: deskInLeft .24s cubic-bezier(.2, .7, .2, 1); }

  /* Tutorial: kotak di sebelah kanan menu, anak panah ke kiri */
  .tour.nodim .tour-tip.side { right: auto; margin: 0; width: 360px; }
  .tour.nodim .tour-tip.side::after { left: -9px; bottom: auto; top: var(--ay, 50%); transform: translateY(-50%) rotate(45deg);
    box-shadow: -2px 2px 0 0 var(--green); border-radius: 0 0 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Peringatan akaun tetamu */
.banner.guest-card { display: block; }
.guest-card .row { align-items: flex-start; }
.guest-card .row + .row { align-items: center; }
