/* Rumah Hoomey (/rumah/ + /akaun/): pemilih profil (mesra kanak-kanak) + kawasan ibu bapa (tenang).
   Berdiri sendiri — tidak perlukan brand.css (kalau ada, dimuat dahulu dan token di sini sebagai sandaran). */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&display=swap');
:root {
  --bg: #FFF8EC; --ink: #33262B; --muted: #8A7A70; --line: #F0E2CF;
  --pink: #FF5C7A; --yellow: #FFD23F; --blue: #3B82F6; --green: #2EBD8C; --orange: #F7A440; --purple: #B07CFF;
  --outline: 5px solid var(--ink); --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: 'Baloo 2', ui-rounded, system-ui, sans-serif; }
body { min-height: 100dvh; display: flex; flex-direction: column; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button, input { font: inherit; color: inherit; }
img, svg { -webkit-user-drag: none; }
@keyframes tma-pop-in { from { transform: scale(.4); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes tma-wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-4deg) } 75% { transform: rotate(4deg) } }
@keyframes ix-in-f { from { opacity: 0; transform: scale(.94); } }
@keyframes ix-spin { to { transform: rotate(360deg); } }
@keyframes rm-bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
.wiggle { animation: tma-wiggle .35s ease-in-out 2; }
.rig { transform-box: fill-box; transform-origin: 50% 100%; }

/* bar atas */
.rm-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(12px + var(--safe-t)) 18px 4px; min-height: 76px; }
.rm-logo { height: 46px; width: auto; display: block; }
.rm-logo-txt { font-size: 34px; font-weight: 800; letter-spacing: .5px; }
.rm-top-kanan { display: flex; gap: 10px; align-items: center; }
.rm-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 58px; padding: 4px 18px 4px 8px; border-radius: 999px; border: 4px solid var(--ink);
  background: #fff; color: var(--ink); font-size: 18px; font-weight: 800; text-decoration: none; cursor: pointer; box-shadow: 0 5px 0 rgba(51,38,43,.2); }
.rm-pill svg { width: 38px; height: 38px; flex: none; }
.rm-pill:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(51,38,43,.2); }
.rm-pill .pr-av { width: 44px; height: 44px; border-width: 3px; }

#skrin { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 16px calc(20px + var(--safe-b)); }
#skrin > * { animation: ix-in-f .3s ease-out both; }
.rm-muat { width: 64px; height: 64px; border-radius: 50%; border: 8px solid var(--line); border-top-color: var(--pink); animation: ix-spin 1s linear infinite; }

/* ---------- avatar ---------- */
.pr-av { position: relative; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; border-radius: 50%; border: 6px solid var(--ink); flex: none; }
.pr-av svg { width: 104%; height: auto; margin-bottom: -12%; }

/* ---------- "Siapa main hari ni?" (kanak-kanak) ---------- */
.rm-tanya { margin: 0 0 18px; font-size: clamp(34px, 5.4vw, 56px); font-weight: 800; line-height: 1.05; text-align: center; }
.rm-profil-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(14px, 3vw, 34px); max-width: 1100px; }
.rm-kad { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(156px, 20vw, 220px); padding: 0; border: 0; background: none; cursor: pointer;
  animation: tma-pop-in .45s cubic-bezier(.3,1.5,.5,1) both; }
.rm-kad .pr-av { width: clamp(140px, 18vw, 188px); height: clamp(140px, 18vw, 188px); box-shadow: 0 8px 0 rgba(51,38,43,.22); transition: transform .15s; }
.rm-kad:active .pr-av { transform: translateY(5px) scale(.97); box-shadow: 0 3px 0 rgba(51,38,43,.22); }
.rm-kad b { font-size: clamp(24px, 2.8vw, 32px); font-weight: 800; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #fff; border: 4px solid var(--ink); border-radius: 999px; padding: 0 18px; }
.rm-kad.terakhir .pr-av { border-color: var(--pink); box-shadow: 0 0 0 7px #FFD1DA, 0 10px 0 rgba(51,38,43,.22); animation: rm-bob 2.2s ease-in-out infinite; }
.rm-kad.terakhir b { background: var(--pink); color: #fff; }
.rm-tambah .rm-plus { width: clamp(140px, 18vw, 188px); height: clamp(140px, 18vw, 188px); border-radius: 50%; border: 6px dashed var(--ink); background: #fff;
  display: flex; align-items: center; justify-content: center; }
.rm-tambah .rm-plus svg { width: 46%; height: 46%; }
.rm-tambah b { background: #F3EADF; font-size: clamp(21px, 2.3vw, 27px); padding: 0 14px; }
.rm-tambah small { display: flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 800; color: var(--muted); margin-top: -4px; }
.rm-tambah small svg { width: 20px; height: 20px; }
.rm-urus { margin-top: 22px; }
.rm-nota { margin: 14px 0 0; font-size: 16px; font-weight: 700; color: var(--muted); text-align: center; max-width: 520px; }

/* ---------- pilih app ---------- */
.rm-app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 420px)); gap: clamp(16px, 3vw, 34px); width: 100%; justify-content: center; }
.rm-app { position: relative; display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; border: 6px solid var(--ink); border-radius: 36px;
  background: #fff; color: var(--ink); text-decoration: none; box-shadow: 0 10px 0 rgba(51,38,43,.22); animation: tma-pop-in .45s cubic-bezier(.3,1.5,.5,1) both; }
a.rm-app:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(51,38,43,.22); }
.rm-app-seni { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; background: #9ED8F2; border-bottom: 6px solid var(--ink); overflow: hidden; }
.rm-app-seni img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rm-app-seni .rm-ganti { display: flex; align-items: flex-end; justify-content: center; gap: 4%; width: 100%; height: 100%; padding: 8% 6% 0; }
.rm-ganti svg { width: 30%; height: auto; }
.rm-app-kaki { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 14px; }
.rm-app-kaki b { font-size: clamp(26px, 3vw, 34px); font-weight: 800; line-height: 1.05; }
.rm-app-kaki small { display: block; font-size: 17px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.rm-main { flex: none; display: flex; align-items: center; gap: 6px; min-height: 64px; padding: 4px 22px 4px 14px; border-radius: 999px; border: 4px solid var(--ink);
  background: var(--green); color: #fff; font-size: 24px; font-weight: 800; box-shadow: 0 5px 0 rgba(51,38,43,.22); }
.rm-main svg { width: 34px; height: 34px; }
.rm-app.tutup { cursor: default; }
.rm-app.tutup .rm-app-seni { filter: saturate(.55); }
.rm-app.tutup .rm-main { background: #CFC4B8; color: var(--ink); }
.rm-reben { position: absolute; top: 26px; right: -54px; transform: rotate(35deg); background: var(--yellow); border-block: 4px solid var(--ink); width: 220px; text-align: center;
  font-size: 20px; font-weight: 800; padding: 2px 0; z-index: 2; }

/* ---------- borang profil (ibu bapa) ---------- */
.ak-card.pr-borang { text-align: left; width: min(640px, 100%); }
.pr-borang .ak-tag, .pr-borang .ak-h { display: flex; justify-content: center; }
.pr-borang .ak-tag { width: max-content; margin: 0 auto; }
.pr-lbl { display: block; margin: 12px 0 6px; font-size: 19px; font-weight: 800; }
.pr-lbl i { font-style: normal; font-weight: 600; color: var(--muted); font-size: 16px; }
.pr-input { width: 100%; min-height: 64px; padding: 6px 18px; border: 4px solid var(--ink); border-radius: 20px; background: #fff; font-size: 24px; font-weight: 700;
  -webkit-user-select: text; user-select: text; }
.pr-input:focus { outline: none; box-shadow: 0 0 0 5px #BFD8FF; }
.pr-watak { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pr-w { display: flex; flex-direction: column; align-items: center; padding: 4px 2px 2px; border: 4px solid var(--line); border-radius: 20px; background: var(--wb, #fff); cursor: pointer; min-height: 88px; }
.pr-w svg { width: 100%; max-width: 76px; height: auto; }
.pr-w b { font-size: 15px; font-weight: 800; line-height: 1.1; }
.pr-w.on { border-color: var(--ink); box-shadow: 0 0 0 4px var(--pink); }
.pr-umur-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pr-umur { min-width: 52px; min-height: 56px; padding: 0 10px; border: 4px solid var(--ink); border-radius: 16px; background: #fff; font-size: 22px; font-weight: 800; cursor: pointer; }
.pr-umur[data-u=""] { font-size: 17px; }
.pr-umur.on { background: var(--blue); color: #fff; }

/* ---------- /akaun/ ---------- */
.ak-hal { width: min(760px, 100%); display: flex; flex-direction: column; gap: 18px; align-self: center; }
.ak-hal .ak-card { width: 100%; text-align: left; }
.ak-hal .ak-tag { margin-bottom: 4px; }
.ak-senarai { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ak-senarai li { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 4px solid var(--ink); border-radius: 24px; background: #fff; }
.ak-senarai .pr-av { width: 72px; height: 72px; border-width: 4px; }
.ak-senarai .ak-info-p { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ak-senarai .ak-info-p b { font-size: 23px; font-weight: 800; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-senarai .ak-info-p span { font-size: 16px; font-weight: 600; color: #5A4A50; }
.ak-senarai .ak-btn { min-height: 56px; padding: 4px 16px; font-size: 18px; }
.ak-senarai .ak-btn svg { width: 28px; height: 28px; }
.ak-polisi-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 17px; font-weight: 700; }
.ak-polisi-row a { color: var(--blue); }
.ak-sah { margin-top: 10px; padding: 12px 14px; border: 4px solid var(--ink); border-radius: 22px; background: #FFE0E6; }
.ak-sah p { margin: 0 0 8px; font-size: 17px; font-weight: 700; }

@media (max-width: 600px) {
  .rm-top { padding-left: 12px; padding-right: 12px; }
  .rm-logo { height: 34px; }
  .rm-pill { min-height: 52px; font-size: 16px; padding: 2px 14px 2px 6px; }
  .rm-pill svg { width: 32px; height: 32px; }
  .rm-profil-grid { gap: 16px 14px; }
  .rm-kad { width: 156px; }
  .rm-tambah b { font-size: 19px; }
  .rm-kad .pr-av, .rm-tambah .rm-plus { width: 140px; height: 140px; }
  .rm-kad b { font-size: 22px; padding: 0 12px; }
  .rm-app-grid { grid-template-columns: minmax(0, 1fr); max-width: 420px; }
  .rm-app-seni { aspect-ratio: 16 / 9; }
  .pr-watak { grid-template-columns: repeat(3, 1fr); }
  .ak-senarai li { flex-wrap: wrap; }
  .ak-senarai .ak-row-p { width: 100%; display: flex; gap: 8px; }
  .ak-senarai .ak-row-p .ak-btn { flex: 1; }
}
@media (orientation: landscape) and (max-height: 860px) and (min-width: 700px) {
  .rm-app-seni { aspect-ratio: 16 / 10; }
  .rm-app-grid { grid-template-columns: repeat(2, minmax(0, 400px)); }
}
/* 3 app atau lebih: 3 lajur pada skrin lebar (telefon kekal 1 lajur) */
@media (min-width: 900px) { .rm-app-grid:has(> :nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 360px)); } }
@media (prefers-reduced-motion: reduce) { .rm-kad.terakhir .pr-av { animation: none; } }
.rm-pill > span:not(.pr-av) { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { .rm-pill > span:not(.pr-av) { max-width: 96px; } }
/* butang "Pasang" (shared/pasang.js) dalam kepala */
.rm-slot-pasang:empty { display: none; }
@media (max-width: 430px) { .rm-top-kanan { gap: 6px; } .rm-top .rm-logo { max-width: 120px; } .rm-pill.hp-pasang-btn { padding: 2px 12px 2px 6px; gap: 4px; } .rm-pill.hp-pasang-btn svg { width: 32px; height: 32px; } }

/* ===== Audit UI Okt 2026 ===== */
/* Nama profil panjang: balut 2 baris (bukan "Muhamma…") */
.rm-kad b { white-space: normal; text-align: center; border-radius: 26px; padding: 2px 16px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.rm-tambah b { -webkit-line-clamp: 2; }
@media (max-width: 600px) { .rm-kad b { font-size: 20px; padding: 2px 12px; } .rm-tambah b { font-size: 18px; } }

/* Telefon potret: kepala 2 baris — tiada skrol mendatar (Pasang + Ibu bapa/Tukar/Kembali tidak muat satu baris) */
@media (max-width: 520px) {
  .rm-top { flex-wrap: wrap; row-gap: 8px; min-height: 0; }
  .rm-top > .rm-top-kanan { display: contents; }
  .rm-top #slot-pasang { margin-left: auto; }
  .rm-top #top-kanan { margin-left: auto; }
  .rm-top #top-kanan:empty { display: none; }
  .rm-pill > span:not(.pr-av) { max-width: 190px; }
}

/* Pilih app — tablet potret & telefon landskap: 3 lajur, kaki bertingkat (tajuk atas, butang bawah) — tiada kad yatim, semua nampak tanpa skrol */
@media (orientation: portrait) and (min-width: 700px), (orientation: landscape) and (max-height: 500px) {
  .rm-app-grid, .rm-app-grid:has(> :nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 360px)); max-width: none; }
  .rm-app-kaki { flex-direction: column; align-items: stretch; text-align: center; gap: 8px; }
  .rm-main { justify-content: center; }
}
@media (orientation: portrait) and (min-width: 700px) { .rm-app-seni { aspect-ratio: 1 / 1; } }
@media (orientation: landscape) and (max-height: 500px) {
  .rm-top { min-height: 0; padding-top: calc(8px + var(--safe-t)); }
  #skrin { padding-top: 0; }
  .rm-tanya { font-size: 30px; margin-bottom: 10px; }
  .rm-app-grid { gap: 14px; }
  .rm-app { border-width: 5px; border-radius: 28px; }
  .rm-app-seni { aspect-ratio: 5 / 2; border-bottom-width: 5px; }
  .rm-app-kaki { padding: 8px 12px 10px; gap: 6px; }
  .rm-app-kaki b { font-size: 22px; }
  .rm-app-kaki small { font-size: 14px; }
  .rm-main { min-height: 56px; font-size: 21px; }
  .rm-main svg { width: 28px; height: 28px; }
  /* pemilih profil */
  .rm-tanya + .rm-profil-grid .rm-kad .pr-av, .rm-tambah .rm-plus { width: 120px; height: 120px; }
  .rm-kad { width: 150px; }
}
/* Telefon potret: kad mendatar (seni kiri, nama + butang kanan) — 3 app nampak serentak tanpa skrol */
@media (max-width: 600px) and (orientation: portrait) {
  .rm-tanya { font-size: 32px; margin-bottom: 12px; }
  .rm-app-grid { gap: 14px; }
  .rm-app { flex-direction: row; border-radius: 30px; min-height: 150px; }
  .rm-app-seni { aspect-ratio: auto; width: 44%; flex: none; border-bottom: 0; border-right: 6px solid var(--ink); }
  .rm-app-kaki { flex: 1; min-width: 0; flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; padding: 10px 12px; }
  .rm-app-kaki b { font-size: 23px; }
  .rm-app-kaki small { font-size: 14px; }
  .rm-main { justify-content: center; min-height: 58px; font-size: 21px; padding: 4px 16px 4px 10px; }
  .rm-main svg { width: 28px; height: 28px; }
}

/* mod tetamu: pil "Tetamu · Daftar percuma" */
.rm-daftar .rm-daftar-lbl { background: #2EBD8C; color: #fff; border-radius: 999px; padding: 4px 12px; font-weight: 800; }
