/* JRC Semak Nilai + Iklan Rumah. Warna HANYA dari token di :root, gelap ikut sistem (prefers-color-scheme). */
:root {
  color-scheme: light dark;
  --bg: #FFFFFF;
  --surface: #F9FAFB;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --border: #E5E7EB;
  --primary: #1B4D3E;
  --primary-hover: #2A7A5F;
  --on-primary: #FFFFFF;
  --brand-text: #1B4D3E;
  --accent: #F59E0B;
  --accent-soft: #FEF3C7;
  --accent-ink: #78350F;
  --sel-bg: #ECFDF5;
  --sel-border: #1B4D3E;
  --ok-soft: #DEF7EC;
  --wa: #25D366;
  --on-wa: #052E16;
  --danger: #B91C1C;
  --danger-soft: #FEF2F2;
  --field: #F9FAFB;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --scrim: rgba(17, 24, 39, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161B26;
    --surface: #1B2130;
    --card: #1F2635;
    --text: #E6EAF2;
    --muted: #A8B2C3;
    --border: #2E3747;
    --primary: #2A7A5F;
    --primary-hover: #33906F;
    --on-primary: #FFFFFF;
    --brand-text: #5CC49A;
    --accent: #FBBF24;
    --accent-soft: #3A2F14;
    --accent-ink: #FDE68A;
    --sel-bg: #1D3A31;
    --sel-border: #5CC49A;
    --ok-soft: #1D3A31;
    --wa: #25D366;
    --on-wa: #052E16;
    --danger: #FCA5A5;
    --danger-soft: #3B1D22;
    --field: #161B26;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --scrim: rgba(255, 255, 255, 0.04);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55;
  -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh;
}
a { color: var(--brand-text); }
button { font-family: inherit; }
[hidden] { display: none !important; }

/* TOPBAR */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 560px; margin: 0 auto; height: 56px; padding: 0 12px; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.15rem; font-weight: 800; color: var(--brand-text); text-decoration: none; }
.logo span { color: var(--accent); }
.btn-ikon {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-ikon:hover { background: var(--scrim); }
.btn-ikon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-ikon.kosong { visibility: hidden; }

/* PROGRESS DOTS */
.dots { display: flex; gap: 8px; justify-content: center; padding: 14px 0 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: .25s; }
.dot.done { background: var(--accent); }
.dot.aktif { background: var(--primary); width: 28px; border-radius: 6px; }

/* SKRIN */
.skrin { display: none; max-width: 560px; margin: 0 auto; padding: 12px 20px 140px; animation: masuk .25s ease; }
.skrin.aktif { display: block; }
@keyframes masuk { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); font-weight: 900; line-height: 1.15; letter-spacing: -0.02em; margin: 6px 0 12px; }
.h2 { font-size: 1.45rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; margin: 10px 0 18px; }
.sub { color: var(--muted); font-size: 1.02rem; margin-bottom: 18px; }

/* HERO */
.hero-foto { margin: 4px -20px 18px; height: 230px; overflow: hidden; position: relative; }
.hero-foto picture { display: block; height: 100%; }
.hero-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-foto::after { content: ''; position: absolute; inset: auto 0 0 0; height: 60px; background: linear-gradient(transparent, var(--bg)); }

/* SOALAN LAZIM (bawah hero funnel, details/summary asli, boleh lipat tanpa JS) */
.faq { margin-top: 30px; }
.faq .h2 { font-size: 1.2rem; margin: 0 0 6px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
  list-style: none; cursor: pointer; position: relative; min-height: 52px; padding: 15px 40px 15px 0;
  font-weight: 700; font-size: 1rem; line-height: 1.4; color: var(--text);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ''; position: absolute; right: 8px; top: 50%; width: 10px; height: 10px; margin-top: -7px;
  border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); transition: transform .2s;
}
.faq-item[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.faq-item summary:focus-visible { outline: 2px solid var(--sel-border); outline-offset: 2px; border-radius: 6px; }
.faq-item p { color: var(--muted); font-size: .95rem; padding: 0 0 16px; }

/* MEDAN */
.medan { margin-bottom: 16px; }
.medan > label, .medan > .label { display: block; font-size: .92rem; font-weight: 700; margin-bottom: 8px; }
.medan input, .medan select, .medan textarea {
  width: 100%; min-height: 52px; padding: 13px 16px; border: 2px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 1rem; color: var(--text); background: var(--field); transition: border-color .15s;
  -webkit-appearance: none; appearance: none;
}
.medan select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  padding-right: 40px;
}
.medan textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.medan input:focus, .medan select:focus, .medan textarea:focus { outline: none; border-color: var(--sel-border); }
.medan input::placeholder, .medan textarea::placeholder { color: var(--muted); opacity: .85; }
.hint { font-size: .84rem; color: var(--muted); margin-top: 6px; }
.soalan { font-size: 1rem; font-weight: 700; margin: 4px 0 10px; }

/* PILIHAN */
.pilihan { display: grid; gap: 8px; margin-bottom: 18px; }
.pilihan.dua { grid-template-columns: 1fr 1fr; }
.pilihan.lima { grid-template-columns: repeat(5, 1fr); }
.pil {
  min-height: 50px; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; background: var(--card);
  color: var(--text); font-size: .98rem; font-weight: 600; text-align: left; cursor: pointer; transition: .15s;
  display: flex; align-items: center; gap: 12px;
}
.pilihan.lima .pil { justify-content: center; text-align: center; padding: 12px 4px; }
.pil:hover { border-color: var(--sel-border); }
.pil[aria-pressed="true"] { border-color: var(--sel-border); background: var(--sel-bg); }
.pil .tanda { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; position: relative; }
.pil[aria-pressed="true"] .tanda { border-color: var(--sel-border); background: var(--sel-border); box-shadow: inset 0 0 0 3px var(--card); }

/* CTA BAR (sentiasa nampak tanpa skrol) */
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg);
  border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.cta-in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
/* Butang utama sentiasa penuh lebar, butang kedua di bawahnya (DOM: kedua dulu, column-reverse) */
.cta-baris { display: flex; flex-direction: column-reverse; gap: 8px; }
.btn {
  width: 100%; min-height: 54px; padding: 14px 18px; border: 0; border-radius: 14px; cursor: pointer;
  font-size: 1.04rem; font-weight: 800; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; transition: background .15s, opacity .15s; text-align: center; line-height: 1.25;
}
.btn-utama { background: var(--primary); color: var(--on-primary); }
.btn-utama:hover { background: var(--primary-hover); }
.btn-utama:disabled { opacity: .45; cursor: not-allowed; }
.btn-kedua { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn-kedua:hover { border-color: var(--sel-border); }
.btn-wa { background: var(--wa); color: var(--on-wa); }
.btn-wa svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.cta-baris .btn-kedua { min-height: 48px; padding: 10px 18px; }
.percaya { text-align: center; font-size: .82rem; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.percaya svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }

/* RALAT DAN MUAT */
.ralat { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 12px 14px; font-size: .92rem; font-weight: 600; margin: 8px 0 14px; }
.muat { display: flex; justify-content: center; padding: 120px 0; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--primary); animation: pusing .8s linear infinite; }
@keyframes pusing { to { transform: rotate(360deg); } }

/* KEPUTUSAN */
.kad-nilai { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin: 8px 0 22px; }
.kad-nilai .label { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.angka { font-size: clamp(1.55rem, 7.4vw, 2.05rem); font-weight: 900; letter-spacing: -0.02em; color: var(--brand-text); margin: 6px 0 10px; line-height: 1.15; }
.asas { font-size: .88rem; color: var(--muted); }
.tawaran { border: 2px solid var(--accent); background: var(--accent-soft); border-radius: 18px; padding: 18px; }
.tawaran .h2 { margin: 0 0 6px; font-size: 1.25rem; }
.pakej { font-weight: 800; color: var(--accent-ink); margin-bottom: 12px; }
.senarai-tanda { list-style: none; display: grid; gap: 10px; }
.senarai-tanda li { display: flex; gap: 10px; font-size: .95rem; line-height: 1.45; }
.senarai-tanda li::before {
  content: ''; flex: 0 0 20px; height: 20px; margin-top: 1px; border-radius: 50%; background: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* GAMBAR */
.grid-gambar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); }
.gb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gb.naik img { opacity: .45; }
.gb.naik::after { content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: pusing .8s linear infinite; }
.gb-buang { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(17, 24, 39, .72); color: #FFFFFF; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.gb-buang svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.gb-tambah { aspect-ratio: 1; border-radius: 10px; border: 2px dashed var(--border); background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.gb-tambah:hover { border-color: var(--sel-border); color: var(--brand-text); }
.gb-tambah svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }

/* IKLAN (pratonton + halaman pembeli) */
.wrap { max-width: 560px; margin: 0 auto; padding: 16px 20px 120px; }
.kad-pratonton { background: var(--card); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 14px; }
.kad-pratonton .badan { padding: 16px; }
.galeri { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 6px; border-radius: 14px; margin-bottom: 14px; scrollbar-width: none; }
.galeri::-webkit-scrollbar { display: none; }
.galeri img { flex: 0 0 100%; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: start; border-radius: 14px; background: var(--surface); }
.kad-pratonton .galeri { border-radius: 0; margin: 0; }
.kad-pratonton .galeri img { border-radius: 0; }
/* Lebih satu gambar: gambar seterusnya mengintai di tepi supaya nampak boleh leret */
.galeri.banyak img { flex-basis: 86%; width: 86%; }
.pautan-lain { margin-top: 18px; }
.iklan-tajuk { font-size: 1.35rem; font-weight: 800; line-height: 1.25; margin: 4px 0 10px; }
.kv { font-size: .98rem; margin-bottom: 4px; }
.kv .k { color: var(--muted); font-weight: 600; }
.kv-harga .v { font-size: 1.3rem; font-weight: 900; color: var(--brand-text); }
.iklan-isi { margin: 14px 0; }
.iklan-isi p { margin-bottom: 12px; font-size: 1rem; }
.kotak-nota { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: .88rem; color: var(--muted); margin: 12px 0; }

/* SENARAI */
.grid-iklan { display: grid; gap: 14px; }
.kad-iklan { display: block; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.kad-iklan img, .kad-tiada-gambar { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; background: var(--surface); }
.kad-badan { padding: 12px 14px 14px; }
.kad-harga { font-weight: 900; font-size: 1.15rem; color: var(--brand-text); }
.kad-tajuk { font-weight: 700; margin: 2px 0; }
.kad-lokasi { font-size: .88rem; color: var(--muted); }
.kosong { color: var(--muted); padding: 40px 0; text-align: center; }

/* ARTIKEL (tools/build_artikel.py, /artikel/ dan /artikel/<slug>/) */
.wrap.artikel { max-width: 680px; padding-bottom: 40px; }
.remah { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin: 4px 0 10px; }
.remah a { color: var(--muted); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.remah a:hover { color: var(--brand-text); text-decoration: underline; }
.oleh { font-size: .88rem; color: var(--muted); margin: -4px 0 18px; }
.artikel-isi { font-size: 1.04rem; line-height: 1.7; }
.artikel-isi h2 { font-size: 1.35rem; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em; margin: 34px 0 12px; }
.artikel-isi h3 { font-size: 1.12rem; font-weight: 800; line-height: 1.3; margin: 24px 0 8px; }
.artikel-isi h4 { font-size: 1rem; font-weight: 700; margin: 18px 0 6px; }
.artikel-isi p, .artikel-isi ul, .artikel-isi ol, .artikel-isi blockquote { margin-bottom: 14px; }
.artikel-isi ul, .artikel-isi ol { padding-left: 1.3em; }
.artikel-isi li { margin-bottom: 6px; }
.artikel-isi li > ul, .artikel-isi li > ol { margin: 6px 0 0; }
.artikel-isi a { text-underline-offset: 2px; overflow-wrap: anywhere; }
.artikel-isi strong { font-weight: 700; }
.artikel-isi blockquote { border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 12px 12px 0; padding: 12px 14px; color: var(--text); }
.artikel-isi blockquote p { margin: 0; }
.artikel-isi code { font-size: .92em; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.artikel-isi hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }
.artikel-isi .p-btn { margin: 4px 0 22px; }
.jadual { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.jadual table { width: 100%; border-collapse: collapse; font-size: .92rem; line-height: 1.45; }
.jadual th, .jadual td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.jadual th { background: var(--surface); font-weight: 700; }
.jadual tr:last-child td { border-bottom: 0; }
.kotak-cta { background: var(--sel-bg); border: 1px solid var(--sel-border); border-radius: 18px; padding: 20px; margin: 30px 0 8px; }
.kotak-cta .h2 { margin: 0 0 8px; font-size: 1.3rem; }
.kotak-cta p { margin-bottom: 16px; }
.sumber { margin-top: 30px; font-size: .9rem; color: var(--muted); }
.sumber .h2 { font-size: 1.15rem; margin-bottom: 10px; color: var(--text); }
.sumber ol { padding-left: 1.3em; display: grid; gap: 6px; }
.sumber a { overflow-wrap: anywhere; }
.senarai-artikel { display: grid; gap: 12px; margin: 8px 0 10px; }
.kad-artikel { display: block; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.kad-artikel:hover { border-color: var(--sel-border); }
.kad-artikel h2 { font-size: 1.1rem; font-weight: 800; line-height: 1.3; margin-bottom: 6px; color: var(--brand-text); }
.kad-artikel p { font-size: .94rem; color: var(--muted); }
.kaki { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .88rem; text-align: center; padding: 26px 20px calc(26px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.kaki a { color: var(--muted); }
.kaki .logo { color: var(--brand-text); font-size: 1.05rem; }

/* STATUS */
.status-ikon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 24px 0 8px; }
.status-ikon.ok { background: var(--ok-soft); color: var(--brand-text); }
.status-ikon.belum { background: var(--accent-soft); color: var(--accent-ink); }
.status-ikon svg { width: 32px; height: 32px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 720px) {
  .hero-foto { margin: 8px 0 20px; border-radius: 18px; height: 280px; }
  .grid-iklan { grid-template-columns: 1fr 1fr; }
}
