:root {
  --latar: #14110f;
  --latar-2: #1f1a17;
  --latar-3: #2a2420;
  --krim: #f3e9d7;
  --krim-2: #cbbfa9;
  --pudar: #8f8475;
  --bata: #c0533a;
  --bata-terang: #e06a4e;
  --kuning: #f5c84c;
  --hijau: #3bb273;
  --garis: rgba(243, 233, 215, 0.12);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --atas: 52px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--latar); color: var(--krim); font-family: var(--sans); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: calc(var(--atas) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 12px; display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to bottom, rgba(20, 17, 15, .85), rgba(20, 17, 15, 0));
  max-width: 520px; margin: 0 auto;
}
.tabs { display: flex; gap: 4px; }
.tabs button { padding: 8px 10px; font-size: 15px; font-weight: 600; color: var(--krim-2); border-radius: 999px; }
.tabs button[aria-selected="true"] { color: var(--krim); background: rgba(243, 233, 215, .12); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: rgba(243, 233, 215, .1); }

/* ---------- feed ---------- */
.feed {
  height: 100dvh; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none; max-width: 520px; margin: 0 auto;
}
.feed::-webkit-scrollbar { display: none; }
.slide {
  height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; display: flex; flex-direction: column;
  padding-top: calc(var(--atas) + env(safe-area-inset-top)); position: relative;
}
.bingkai {
  position: relative; width: 100%; aspect-ratio: 4 / 5; max-height: calc(100dvh - var(--atas) - 180px);
  margin: 0 auto; background: var(--latar-2); overflow: hidden; flex: none;
}
@supports (max-height: 1dvh) { .bingkai { width: min(100%, calc((100dvh - var(--atas) - 180px) * .8)); } }
.bingkai video, .bingkai .poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bingkai video { opacity: 0; transition: opacity .15s; }
.bingkai video.main { opacity: 1; }
.bunyi {
  position: absolute; left: 10px; top: 10px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  background: rgba(20, 17, 15, .72); border-radius: 999px; backdrop-filter: blur(6px);
}
.jeda { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.jeda svg { width: 72px; height: 72px; fill: rgba(243, 233, 215, .85); stroke: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }
.progres { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(243, 233, 215, .18); }
.progres i { display: block; height: 100%; width: 0; background: var(--krim); }
.hati-besar { position: absolute; left: 50%; top: 50%; width: 110px; height: 110px; margin: -55px 0 0 -55px; pointer-events: none; opacity: 0; }
.hati-besar.pop { animation: pop .7s ease-out; }
.hati-besar::before {
  content: ''; position: absolute; inset: 0; background: var(--bata-terang);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 20.5s-7.5-4.6-9.3-9.2C1.4 8 3.4 4.5 7 4.5c2 0 3.6 1.1 5 2.9 1.4-1.8 3-2.9 5-2.9 3.6 0 5.6 3.5 4.3 6.8-1.8 4.6-9.3 9.2-9.3 9.2z"/></svg>') center / contain no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 20.5s-7.5-4.6-9.3-9.2C1.4 8 3.4 4.5 7 4.5c2 0 3.6 1.1 5 2.9 1.4-1.8 3-2.9 5-2.9 3.6 0 5.6 3.5 4.3 6.8-1.8 4.6-9.3 9.2-9.3 9.2z"/></svg>') center / contain no-repeat;
}
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: .95; transform: scale(1.1); } 70% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.25) translateY(-20px); } }

.rail { position: absolute; right: 6px; bottom: 14px; display: flex; flex-direction: column; gap: 14px; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.rail-btn svg { width: 32px; height: 32px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); fill: rgba(20,17,15,.25); }
.rail-btn.like.aktif svg { fill: var(--bata-terang); stroke: var(--bata-terang); }
.rail-btn.like.aktif.denyut svg { animation: denyut .35s ease-out; }
@keyframes denyut { 50% { transform: scale(1.3); } }

.info { flex: 1; min-height: 0; padding: 12px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.label { margin: 0; font-size: 11px; letter-spacing: .12em; font-weight: 700; color: var(--bata-terang); text-transform: uppercase; }
.tajuk { margin: 0; font-family: var(--serif); font-weight: 800; font-size: 22px; line-height: 1.15; }
.situasi { margin: 2px 0 0; font-size: 14px; color: var(--krim-2); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sumber { margin: 0; font-size: 12px; color: var(--pudar); }
.info .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.info .tags .chip { font-size: 12px; padding: 5px 10px; }
@media (max-height: 720px) { .info .tags { display: none; } }
.info-aksi { margin-top: auto; padding-top: 6px; display: flex; gap: 8px; }
.btn-template {
  flex: 1; padding: 11px 14px; border-radius: 12px; background: var(--krim); color: var(--latar);
  font-weight: 700; font-size: 15px;
}
.btn-template:active { transform: scale(.98); }
@media (max-height: 640px) { .situasi, .sumber { display: none; } .tajuk { font-size: 19px; } }

.kosong { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--krim-2); }
.kosong-tajuk { font-family: var(--serif); font-size: 24px; color: var(--krim); margin: 0 0 6px; }

/* ---------- search ---------- */
.cari { position: fixed; inset: 0; z-index: 30; background: var(--latar); overflow-y: auto; max-width: 520px; margin: 0 auto; padding: env(safe-area-inset-top) 0 24px; }
.cari-bar { position: sticky; top: 0; display: flex; align-items: center; gap: 4px; padding: 6px 12px 6px 4px; background: var(--latar); z-index: 1; }
#cari-input {
  flex: 1; height: 42px; border-radius: 12px; border: 1px solid var(--garis); background: var(--latar-2);
  color: var(--krim); padding: 0 14px; font: inherit; font-size: 16px; outline: none;
}
#cari-input:focus { border-color: var(--krim-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 10px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--latar-3); color: var(--krim-2); font-size: 13px; font-weight: 600; }
.chip:active, .chip.aktif { background: var(--krim); color: var(--latar); }
.cari-hasil { list-style: none; margin: 0; padding: 0 12px; display: grid; gap: 8px; }
.cari-hasil button { width: 100%; display: flex; gap: 12px; text-align: left; padding: 8px; border-radius: 12px; background: var(--latar-2); }
.cari-hasil img { width: 72px; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 8px; flex: none; background: var(--latar-3); }
.cari-hasil .h-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--bata-terang); }
.cari-hasil .h-tajuk { font-family: var(--serif); font-size: 17px; font-weight: 700; margin: 2px 0; }
.cari-hasil .h-petikan { font-size: 13px; color: var(--krim-2); line-height: 1.35; }
.cari-hasil mark { background: none; color: var(--kuning); font-weight: 700; }
.cari-status { color: var(--pudar); text-align: center; font-size: 14px; padding: 16px; margin: 0; }

/* ---------- bottom sheet ---------- */
.sheet-latar { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  max-height: 78dvh; display: flex; flex-direction: column; background: var(--latar-2);
  border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: naik .22s ease-out;
}
@keyframes naik { from { transform: translateY(40px); opacity: 0; } }
.sheet-pemegang { width: 40px; height: 4px; border-radius: 4px; background: var(--garis); margin: 8px auto 4px; flex: none; }
#sheet-isi { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-kepala { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px 18px; flex: none; }
.sheet-kepala h3 { margin: 0; font-size: 16px; }
.sheet-badan { overflow-y: auto; padding: 0 18px 16px; flex: 1; min-height: 0; }

/* comments */
.komen-senarai { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.komen-senarai li.balas { margin-left: 34px; }
.k-baris { display: flex; gap: 10px; }
.k-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--latar-3); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; color: var(--krim-2); }
.k-nama { font-size: 12px; font-weight: 600; color: var(--krim-2); }
.k-isi { font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; margin: 2px 0 4px; }
.k-meta { display: flex; gap: 14px; font-size: 12px; color: var(--pudar); align-items: center; flex-wrap: wrap; }
.k-meta button { color: var(--pudar); font-weight: 600; font-size: 12px; }
.k-status { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--latar-3); color: var(--kuning); }
.k-gagal { color: var(--bata-terang); }
.komen-tulis { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--garis); flex: none; align-items: flex-end; }
.komen-tulis textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px; border-radius: 12px; border: 1px solid var(--garis);
  background: var(--latar); color: var(--krim); padding: 10px 12px; font: inherit; font-size: 16px; outline: none;
}
.btn-utama { padding: 10px 16px; border-radius: 12px; background: var(--bata); color: #fff; font-weight: 700; }
.btn-utama:disabled { opacity: .5; }
.balas-kepada { font-size: 12px; color: var(--krim-2); padding: 6px 14px 0; display: flex; justify-content: space-between; }
.kosong-kecil { color: var(--pudar); text-align: center; padding: 24px 0; font-size: 14px; }

/* login */
.borang { display: grid; gap: 10px; }
.borang input {
  height: 46px; border-radius: 12px; border: 1px solid var(--garis); background: var(--latar); color: var(--krim);
  padding: 0 14px; font: inherit; font-size: 16px; outline: none;
}
.borang input:focus { border-color: var(--krim-2); }
.borang .btn-utama { height: 46px; }
.btn-google { height: 46px; border-radius: 12px; background: #fff; color: #1f1f1f; font-weight: 600; display: flex; gap: 10px; align-items: center; justify-content: center; }
.atau { text-align: center; color: var(--pudar); font-size: 12px; margin: 2px 0; }
.tukar { text-align: center; font-size: 14px; color: var(--krim-2); }
.tukar button { color: var(--kuning); font-weight: 600; }
.ralat { color: var(--bata-terang); font-size: 13px; min-height: 18px; margin: 0; }
.nota { color: var(--pudar); font-size: 13px; margin: 0 0 12px; line-height: 1.4; }

/* template */
.template-kotak {
  white-space: pre-wrap; background: #e7f3e0; color: #1c2a17; border-radius: 12px 12px 12px 2px; padding: 12px 14px;
  font-size: 15px; line-height: 1.45; margin: 4px 0 12px;
}
.template-aksi { display: grid; gap: 8px; }
.btn-cta { display: block; text-align: center; padding: 12px; border-radius: 12px; border: 1px solid var(--garis); color: var(--krim); text-decoration: none; font-weight: 600; font-size: 14px; }
.kajian { font-size: 13px; color: var(--krim-2); line-height: 1.45; margin: 0 0 12px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--krim); color: var(--latar); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: calc(100vw - 32px);
}

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