/* Reka bentuk responsif: telefon (asal) → tablet (≥768px, rel sisi) → desktop (≥1024px, bar sisi).
   Telefon tidak diubah; semua peraturan di bawah hanya aktif pada skrin lebar dan tinggi yang mencukupi
   (telefon dalam mod landskap kekal dengan reka bentuk telefon). */

.bn-brand { display: none; }
/* Takuk/bar sistem pada sisi skrin (landskap) */
.app { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.app .viewer { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.bn .nl-l { display: none; }

@media (min-width: 768px) and (min-height: 480px) {
  /* ---------- Rangka: bar sisi + kawasan kandungan ---------- */
  .app {
    --rail: 104px;
    --w: 760px;
    --gx: max(32px, calc((100% - var(--w)) / 2 + 32px));
    max-width: none; margin: 0; box-shadow: none;
  }
  .app:not(:has(> .bn)) { --w: 720px; }
  .app:has(.teras-rail, .galeri, .pad > .doc) { --w: 1120px; }
  .app:has(.auth) { --w: 460px; }

  .app:has(> .bn) { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .app:has(> .bn) > .bn { grid-column: 1; grid-row: 1 / -1; }
  .app:has(> .bn) > .ab { grid-column: 2; grid-row: 1; }
  .app:has(> .bn) > .content { grid-column: 2; grid-row: 2; }

  /* ---------- Navigasi: rel ikon (tablet) ---------- */
  .app > .bn { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 18px 8px; background: var(--surface); border-top: 0; border-right: 1px solid var(--line); backdrop-filter: none; overflow-y: auto; scrollbar-width: none; }
  .app > .bn .bn-brand { order: -2; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative; overflow: hidden; margin: -18px -8px 14px; padding: 22px 8px 16px; color: #fff;
    background-color: var(--hero); background-image: linear-gradient(180deg, rgba(10,14,70,.25), rgba(10,14,70,0) 70%), url(../img/bg-rsnj.webp); background-size: 100% 100%, cover; background-position: 0 0, center; }
  .app[data-theme="dark"] > .bn .bn-brand { background-image: linear-gradient(180deg, rgba(5,8,40,.4), rgba(5,8,40,.2)), url(../img/bg-rsnj.webp); }
  @media (prefers-color-scheme: dark) { .app[data-theme="system"] > .bn .bn-brand { background-image: linear-gradient(180deg, rgba(5,8,40,.4), rgba(5,8,40,.2)), url(../img/bg-rsnj.webp); } }
  .app > .bn .bn-brand::after { content: ''; position: absolute; right: -16px; top: -16px; width: 36px; height: 36px; background: var(--merah); transform: rotate(45deg); }
  .bn-brand img { display: block; width: 100%; max-width: 84px; height: auto; position: relative; z-index: 1; }
  .bn-brand small { position: relative; z-index: 1; font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.85); }
  .app > .bn a { flex-direction: column; justify-content: center; gap: 5px; padding: 11px 2px 10px; border-radius: 14px; font-size: 10.5px; color: var(--ink-2); transition: background .15s, color .15s; }
  .app > .bn a svg { width: 22px; height: 22px; }
  .app > .bn .nl-s { display: none; }
  .app > .bn .nl-l { display: inline; }
  .app > .bn a:hover { background: var(--surface-2); }
  .app > .bn a.on { background: var(--pri-soft); color: var(--pri-text); }
  .app > .bn a.on::before { content: ''; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--acc); }
  .app > .bn a.home { order: -1; }
  .app > .bn a.home .disc { width: auto; height: auto; margin: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; }
  .app > .bn a.home.on .disc { background: none; color: inherit; }
  .app > .bn a.home svg { width: 22px; height: 22px; }
  .app > .bn a .badge { top: 6px; left: calc(50% + 8px); box-shadow: 0 0 0 2px var(--surface); }

  /* ---------- Bar tajuk, langkah dan kaki mengikut lajur kandungan ---------- */
  .app .ab { padding: 16px var(--gx) 12px; min-height: 68px; }
  .app .ab h1 { font-size: 20px; }
  .app .ab h1.big { font-size: 30px; padding-left: 0; }
  .app .ab > .ib:first-child { margin-left: -10px; }
  .app .stepper { padding-inline: var(--gx); }
  .app .foot { padding-inline: var(--gx); }
  .app .messages { padding-inline: var(--gx); }
  .app .pad { width: 100%; max-width: var(--w); margin-inline: auto; padding: 24px 32px 56px; }

  /* ---------- Laman utama ---------- */
  .app .content > .hero { padding: 20px var(--gx) 44px; }
  .app .hero::after { width: 130px; height: 130px; right: -48px; top: -48px; }
  .app .hero .hd { position: static; }
  .app .hero .hd .ib { position: absolute; top: 14px; right: 14px; margin: 0; z-index: 3; }
  .app .hero .hd .logos img { height: 40px; }
  .app .hero .hd .logos .lg-pmj { height: 32px; }
  .app .hero .hero-top { grid-template-columns: auto minmax(0, 1fr); gap: 8px 36px; margin-top: 20px; }
  .app .hero .hero-info { padding-left: 36px; }
  .app .hero .hero-top .kick img { height: 200px; }
  .app .hero .hero-info h1 { font-size: 38px; max-width: 22ch; margin-bottom: 20px; }
  .app .hero.closed .hero-info h1 { max-width: 26ch; }
  .app .hero .hero-info p { font-size: 16px; max-width: 52ch; }
  .app .hero .hero-info .count { gap: 16px; }
  .app .hero .hero-info .count .n { font-size: 108px; }
  .app .hero .hero-info .count .u strong { font-size: 21px; }
  .app .hero .hero-info .count .u small { font-size: 14px; }
  .app .hero .prog { margin-top: 28px; }
  .app .hero .prog, .app .hero .prog-l { max-width: none; }
  .app .hero .hero-act { flex-direction: row; gap: 14px; margin-top: 26px; }
  .app .hero .hero-act .btn.block { flex: 1 1 0; width: auto; min-width: 0; max-width: 360px; }

  .app .sec-h { margin-top: 36px; }
  .app .sec-h h2 { font-size: 20px; }
  .app .vis .c { padding: 18px 12px; }
  .app .vis .c b { font-size: 26px; }

  /* ---------- Grid kad ---------- */
  .app .teras-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; overflow: visible; margin: 0; padding: 0; scroll-snap-type: none; }
  .app .galeri { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .app .teras-rail .tp, .app .galeri .tp { width: auto; height: 190px; padding: 16px; }
  .app .tp .k { font-size: 52px; }
  .app .tp strong { font-size: 16px; }
  .app .tp span { font-size: 12px; }
  .app .galeri .vid { grid-column: 1 / -1; height: 200px; }
  .app .pad:has(> .doc) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-content: start; }
  .app .pad:has(> .doc) > .doc + .doc { margin-top: 0; }
  .app .pad:has(> .doc) > :not(.doc) { grid-column: 1 / -1; }
  .app .seg { max-width: 560px; }
  .app .seg[role="tablist"] { max-width: none; }

  /* ---------- Halaman fokus (tanpa navigasi): auth, serahan, slip ---------- */
  .app .auth { max-width: var(--w); margin-inline: auto; padding: 24px 32px 56px; }
  .app .auth > :first-child { margin-bottom: 16px; }
  .app .auth .brandblk.hero { margin: 0 0 28px; border-radius: 20px; padding: 36px 28px 32px; }

  /* Log masuk: panel sepanduk (kiri) + borang (kanan) */
  .app .login { position: relative; flex-direction: row; min-height: 100dvh; overflow: hidden; }
  .app .login::after { content: ''; position: absolute; right: -48px; top: -48px; width: 130px; height: 130px; background: var(--merah); transform: rotate(45deg); z-index: 3; }
  .app .login .lg-hero { flex: 0 0 46%; display: flex; flex-direction: column; padding: 28px 44px 44px; }
  .app .login .lg-hero::after { display: none; }
  .app .login .lg-hero .hd .logos img { height: 40px; }
  .app .login .lg-hero .hd .logos .lg-pmj { height: 32px; }
  .app .login .lg-hero .hero-top { display: flex; flex-direction: column; align-items: flex-start; gap: 26px; margin-block: auto; }
  .app .login .lg-hero .kick img { height: auto; width: min(100%, 400px); margin-left: 0; }
  .app .login .lg-hero .hero-info { padding: 22px 0 0; border-left: 0; border-top: 1px solid; border-image: linear-gradient(90deg, rgba(255,255,255,.5), rgba(255,255,255,0)) 1; max-width: 400px; }
  .app .login .lg-hero .hero-info h1 { font-size: 34px; margin-bottom: 10px; max-width: none; }
  .app .login .lg-hero .hero-info p { font-size: 16px; max-width: 38ch; }
  .app .login .lg-form { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; max-width: none; margin: 0; padding: 48px 32px; }
  .app .login .lg-form > * { width: 100%; max-width: 400px; }
  .app .login .lg-form h2 { font-size: 30px; }
  .app .okscreen { max-width: 560px; margin-inline: auto; padding-top: 56px; }
  .app .lockcard { max-width: 520px; margin: 40px auto; }
  .app .paper { max-width: 680px; margin: 28px auto; padding: 28px 30px 30px; font-size: 12.5px; }
  .app .paper h4 { font-size: 14px; }
  .app .paper th { font-size: 11px; }
  .app .slip-kertas + div { max-width: 680px; margin-inline: auto; }

  /* ---------- Pemapar dokumen ---------- */
  .app .viewer .vt { padding: 12px 16px 10px; }
  .app .viewer .vb { padding: 10px 16px 14px; }
  .app .viewer .pgwrap { width: calc(var(--z, 1) * min(100%, 920px)); }
  .app .viewer .fab { right: 28px; bottom: 84px; }
  .app .viewer .pv-note { top: 76px; left: 20px; }

  /* ---------- Lapisan: lembaran bawah → dialog, toast di sudut ---------- */
  .app .scrim { align-items: center; justify-content: center; }
  .app .sheet { width: min(560px, calc(100% - 48px)); max-height: 80%; border-radius: 24px; padding: 24px 28px 28px; animation: fade .18s ease-out; }
  .app .sheet .grab { display: none; }
  .app .toast { left: auto; right: 24px; bottom: 24px; width: min(440px, calc(100% - 48px)); }
}

/* ---------- Desktop: bar sisi penuh ---------- */
@media (min-width: 1024px) and (min-height: 480px) {
  .app { --rail: 264px; }
  .app > .bn { padding: 24px 16px 20px; gap: 4px; }
  .app > .bn .bn-brand { align-items: flex-start; gap: 10px; margin: -24px -16px 18px; padding: 30px 24px 22px; }
  .app > .bn .bn-brand::after { width: 52px; height: 52px; right: -22px; top: -22px; }
  .bn-brand img { max-width: 176px; }
  .bn-brand small { font-size: 10.5px; }
  .app > .bn a { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 12px 14px; font-size: 14.5px; text-align: left; }
  .app > .bn a.on::before { left: -16px; }
  .app > .bn a .badge { position: static; margin-left: auto; box-shadow: none; }
}

@media (min-width: 1360px) and (min-height: 480px) {
  .app .teras-rail, .app .galeri { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .app .galeri .tp, .app .teras-rail .tp { height: 200px; }
}

/* ---------- Telefon landskap (tinggi < 480px): rel sisi padat, kandungan lebar penuh ---------- */
@media (orientation: landscape) and (max-height: 479px) {
  .app { --rail: 84px; max-width: none; margin: 0; box-shadow: none; }
  .app:has(> .bn) { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .app:has(> .bn) > .bn { grid-column: 1; grid-row: 1 / -1; }
  .app:has(> .bn) > .ab { grid-column: 2; grid-row: 1; }
  .app:has(> .bn) > .content { grid-column: 2; grid-row: 2; }

  .app > .bn { display: flex; flex-direction: column; justify-content: space-around; gap: 2px; padding: 6px 4px max(6px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 0; border-right: 1px solid var(--line); backdrop-filter: none; overflow-y: auto; scrollbar-width: none; }
  .app > .bn a { flex: 1 1 0; max-height: 64px; justify-content: center; gap: 3px; padding: 6px 2px; border-radius: 12px; font-size: 9.5px; }
  .app > .bn a svg, .app > .bn a.home svg { width: 22px; height: 22px; }
  .app > .bn a.on { background: var(--pri-soft); color: var(--pri-text); }
  .app > .bn a.home { order: -1; }
  .app > .bn a.home .disc { width: auto; height: auto; margin: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; }
  .app > .bn a.home.on .disc { background: none; color: inherit; }

  .app .ab { min-height: 44px; padding: 4px 12px; }
  .app .pad { max-width: 880px; margin-inline: auto; padding: 12px 24px 28px; }
  .app .stepper { padding-inline: 24px; }
  .app .foot { padding: 8px 24px max(8px, env(safe-area-inset-bottom)); }
  .app .sec-h { margin-top: 18px; }

  .app .content > .hero { padding: 8px 24px 20px; }
  .app .hero .hero-top .kick img { height: 96px; }
  .app .hero .hero-info h1 { font-size: 22px; margin-bottom: 8px; }
  .app .hero .hero-info .count .n { font-size: 56px; }
  .app .hero .hero-act { flex-direction: row; margin-top: 12px; }
  .app .hero .hero-act .btn.block { flex: 1 1 0; width: auto; max-width: 320px; }
  .app .hero .prog { margin-top: 12px; }

  .app .teras-rail, .app .galeri { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow: visible; margin: 0; padding: 0; scroll-snap-type: none; }
  .app .teras-rail .tp, .app .galeri .tp { width: auto; height: auto; min-height: 150px; }
  .app .galeri .vid { grid-column: 1 / -1; height: 150px; }
  .app .pad:has(> .doc) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; }
  .app .pad:has(> .doc) > .doc + .doc { margin-top: 0; }
  .app .pad:has(> .doc) > :not(.doc) { grid-column: 1 / -1; }

  .app .login { flex-direction: row; min-height: 100%; }
  .app .login .lg-hero { flex: 0 0 44%; padding: 12px 24px 16px; }
  .app .login .lg-hero .hero-top { margin-top: 8px; }
  .app .login .lg-form { flex: 1; min-width: 0; padding: 16px 28px 24px; }
  .app .okscreen { padding-top: 16px; }
  .app .paper { max-width: 680px; margin: 14px auto; }

  .app .viewer .vt { padding-block: max(4px, env(safe-area-inset-top)) 4px; }
  .app .viewer .vb { padding-block: 4px max(6px, env(safe-area-inset-bottom)); }
  .app .viewer .vb .pgi { height: 36px; }
  .app .viewer .pgwrap { width: calc(var(--z, 1) * min(100%, 720px)); }
  .app .viewer .fab { right: 16px; bottom: calc(60px + env(safe-area-inset-bottom)); height: 40px; }

  .app .scrim { align-items: center; justify-content: center; }
  .app .sheet { width: min(560px, calc(100% - 48px)); max-height: 90%; border-radius: 20px; padding: 16px 24px 20px; animation: fade .18s ease-out; }
  .app .sheet .grab { display: none; }
  .app .toast { left: auto; right: 16px; bottom: 16px; width: min(420px, calc(100% - 32px)); }
}

/* Elak zum automatik iOS apabila fokus pada medan borang */
@media (hover: none) and (pointer: coarse) {
  .app .in, .app select, .app textarea, .app .cascade .lv select,
  .app input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]) { font-size: 16px; }
}

/* ---------- Penunjuk tetikus: bar tatal dan kesan lenggang ---------- */
@media (min-width: 768px) and (min-height: 480px) and (pointer: fine) {
  .app .content { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .app .content::-webkit-scrollbar { display: block; width: 10px; }
  .app .content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; border: 2px solid var(--bg); }
}

@media (min-width: 768px) and (min-height: 480px) and (hover: hover) {
  .app a.tp, .app a.doc { transition: transform .18s ease, box-shadow .18s ease; }
  .app a.tp:hover, .app a.doc:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -16px rgba(13, 18, 80, .5); }
  .app a.row:hover { background: var(--surface-2); }
  .app .btn { transition: filter .15s, transform .1s; }
  .app .btn:hover { filter: brightness(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .app a.tp, .app a.doc, .app .btn { transition: none; }
  .app a.tp:hover, .app a.doc:hover { transform: none; }
}
