:root {
  /* Apple HIG dark palette: black canvas, grouped greys, translucent labels, one accent (systemBlue). */
  --latar: #000;
  --latar-2: #1c1c1e;
  --latar-3: #2c2c2e;
  --isian: rgba(118, 118, 128, .24);
  --krim: #fff;
  --krim-2: rgba(235, 235, 245, .62);
  --pudar: rgba(235, 235, 245, .36);
  --bata: #0a84ff;
  --bata-terang: #ff375f;
  --aksen: #0a84ff;
  --kuning: #ffd60a;
  --hijau: #30d158;
  --garis: rgba(84, 84, 88, .55);
  --bahan: rgba(30, 30, 32, .72);
  --serif: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display', 'Segoe UI', Roboto, system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', Roboto, system-ui, 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: 1.75; 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: rgba(0, 0, 0, .55); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  max-width: 520px; margin: 0 auto;
}
.tabs { display: flex; gap: 4px; }
.tabs button { padding: 8px 10px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; color: var(--pudar); transition: color .2s; }
.tabs button[aria-selected="true"] { color: var(--krim); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: var(--isian); }
.topbar-kanan { display: flex; align-items: center; }
/* Admin only: drafts waiting for review (count badge, like an iOS app icon). */
#btn-semak { position: relative; color: var(--krim); }
.lencana { position: absolute; top: 6px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bata-terang); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.lencana:empty { display: none; }

/* ---------- feed ---------- */
/* The feed is pinned to the visible screen (position: fixed) and is the size container for every slide:
   slides and the video frame are sized from the feed's real height (cqh), not from 100dvh, so a card always
   fits the screen it is shown on. app.js re-aligns the snap after any height change (jajarFeed). */
.feed {
  position: fixed; inset: 0; container-type: size;
  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; height: 100cqh; 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)); } }
@supports (height: 1cqh) {
  .bingkai {
    max-height: calc(100cqh - var(--atas) - env(safe-area-inset-top) - 180px - env(safe-area-inset-bottom));
    width: min(100%, calc((100cqh - var(--atas) - env(safe-area-inset-top) - 180px - env(safe-area-inset-bottom)) * .8));
  }
}
.bingkai { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.bingkai video, .bingkai .poster { pointer-events: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bingkai video { opacity: 0; transition: opacity .15s; }
.bingkai video.main { opacity: 1; }
.jeda { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.jeda svg { width: 72px; height: 72px; fill: rgba(255, 255, 255, .9); stroke: none; filter: drop-shadow(0 2px 8px rgba(0,0,0,.5)); }
/* Scrubber: 20px touch target, 3px visible line; thicker + thumb while dragging. */
.progres { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; touch-action: none; cursor: pointer; z-index: 2; }
.progres::before, .progres i { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; transition: height .12s; }
.progres::before { right: 0; background: rgba(255, 255, 255, .22); }
.progres i { width: 0; background: var(--krim); }
.progres b { position: absolute; bottom: -4px; left: 0; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--krim); box-shadow: 0 1px 4px rgba(0,0,0,.5); transform: scale(0); transition: transform .12s; }
.progres.tarik::before, .progres.tarik i { height: 6px; }
.progres.tarik b, .progres:focus-visible b { transform: scale(1); }
.masa {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); padding: 6px 12px; border-radius: 8px;
  background: rgba(20, 17, 15, .78); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none;
}
.laju {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); padding: 5px 12px; border-radius: 999px;
  background: rgba(20, 17, 15, .72); font-size: 13px; font-weight: 700; pointer-events: none;
}
.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: 24px; 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: 30px; height: 30px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); fill: none; }
.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); } }

/* Caption under the video, Facebook / Instagram "See more" pattern:
   collapsed = label 1 line, title 2 lines, situation 2 lines + "more"; source and tags only when expanded.
   Expanded, the caption becomes a sheet laid OVER the video, so the template button never moves.
   The button row is flex: none at the bottom; however long the text is, only the text area is clipped. */
.info {
  --aksi-h: calc(66px + env(safe-area-inset-bottom));
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
}
.teks { flex: 0 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
.label { margin: 0; font-size: 12px; letter-spacing: .02em; font-weight: 600; color: var(--pudar); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.tajuk { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 22px; line-height: 1.18; letter-spacing: -.02em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: none; }
.ringkas { position: relative; margin-top: 2px; flex: none; }
.situasi { margin: 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; }
.lagi {
  position: absolute; right: 0; bottom: 0; padding: 0 0 0 36px; font-size: 14px; line-height: 1.35; font-weight: 600;
  color: var(--krim); background: linear-gradient(90deg, rgba(0, 0, 0, 0), var(--latar) 30px);
}
.lagi::before { content: '… '; color: var(--krim-2); font-weight: 400; }
.lanjut { display: none; }
.sumber { margin: 0; font-size: 12px; color: var(--pudar); line-height: 1.4; }
.info .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.info .tags .chip { font-size: 12px; padding: 5px 10px; }
.info-aksi { flex: none; margin-top: auto; padding-top: 6px; display: flex; gap: 8px; }

.info.kembang .teks {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: var(--aksi-h);
  max-height: calc(100dvh - var(--atas) - env(safe-area-inset-top) - var(--aksi-h) - 16px);
  max-height: calc(100cqh - var(--atas) - env(safe-area-inset-top) - var(--aksi-h) - 16px);
  padding: 16px 16px 12px; overflow-y: auto; overscroll-behavior: contain; gap: 6px;
  background: rgba(0, 0, 0, .84); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-radius: 16px 16px 0 0; box-shadow: 0 -12px 32px rgba(0, 0, 0, .45);
}
.info.kembang .label { white-space: normal; }
.info.kembang .tajuk, .info.kembang .situasi { display: block; overflow: visible; }
.info.kembang .lagi { position: static; display: block; margin-top: 4px; padding: 0; background: none; color: var(--krim-2); text-align: left; }
.info.kembang .lagi::before { content: none; }
.info.kembang .lanjut { display: block; margin-top: 4px; }
.btn-template {
  flex: 1; min-height: 50px; padding: 0 16px; border-radius: 14px; background: var(--krim); color: #000;
  font-weight: 600; font-size: 17px; letter-spacing: -.01em; transition: transform .15s, opacity .15s;
}
.btn-template:active { transform: scale(.97); opacity: .85; }
@container (max-height: 640px) { .info:not(.kembang) .situasi { -webkit-line-clamp: 1; } .tajuk { font-size: 19px; } }

/* New cards: pill under the top bar + pull-to-refresh spinner. Both sit above the feed and never move it. */
.pil-baru {
  position: fixed; z-index: 21; left: 50%; top: calc(var(--atas) + env(safe-area-inset-top) + 10px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 8px 16px 8px 12px; border-radius: 999px;
  background: var(--aksen); color: #fff; font-size: 15px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  animation: pil-masuk .35s cubic-bezier(.32, .72, 0, 1);
}
.pil-baru svg { width: 18px; height: 18px; stroke-width: 2.2; }
.pil-baru:active { opacity: .8; }
@keyframes pil-masuk { from { opacity: 0; transform: translate(-50%, -12px); } }
.tarik {
  position: fixed; z-index: 21; left: 50%; top: calc(var(--atas) + env(safe-area-inset-top) - 30px); width: 36px; height: 36px; margin-left: -18px;
  display: grid; place-items: center; border-radius: 50%; background: var(--latar-3); color: var(--krim);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .15s, background .15s;
}
.tarik.tunjuk { opacity: 1; }
.tarik.sedia { background: var(--aksen); }
.tarik svg { width: 20px; height: 20px; stroke-width: 2.2; }
.tarik.pusing svg { animation: pusing .7s linear infinite; }
@keyframes pusing { to { transform: rotate(360deg); } }

.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: 22px; font-weight: 700; letter-spacing: -.02em; 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: rgba(0,0,0,.72); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); z-index: 1; }
#cari-input {
  flex: 1; height: 40px; border-radius: 10px; border: 0; background: var(--isian);
  color: var(--krim); padding: 0 14px; font: inherit; font-size: 16px; outline: none;
}
#cari-input::placeholder { color: var(--pudar); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 16px 10px; }
.chip { padding: 7px 13px; border-radius: 999px; background: var(--isian); color: var(--krim); font-size: 14px; font-weight: 500; }
.chip:active, .chip.aktif { background: var(--krim); color: #000; }
.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: 10px; border-radius: 14px; 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: 12px; font-weight: 600; color: var(--pudar); }
.cari-hasil .h-tajuk { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -.01em; 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(--aksen); font-weight: 600; }
.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, .4); }
.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(--bahan);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: naik .32s cubic-bezier(.32, .72, 0, 1);
}
/* Comments (TikTok / Shorts pattern): fixed 70% of the screen whatever the count, video visible above,
   list scrolls inside with the header and input pinned. Drag the handle up = full height, down = close. */
.sheet[data-jenis="komen"] { height: 70dvh; max-height: 70dvh; transition: height .2s, max-height .2s; }
.sheet[data-jenis="komen"][data-penuh] { height: 92dvh; max-height: 92dvh; }
.sheet-pemegang, .sheet-kepala { touch-action: none; }
.sheet-pemegang { cursor: grab; padding: 6px 0; box-sizing: content-box; background-clip: content-box; }
@keyframes naik { from { transform: translateY(100%); } }
.sheet-pemegang { width: 36px; height: 5px; border-radius: 3px; background-color: rgba(235, 235, 245, .3); margin: 6px 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: 17px; font-weight: 600; letter-spacing: -.01em; }
.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: 32px; height: 32px; border-radius: 50%; background: var(--isian); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; color: var(--krim-2); }
.k-nama { font-size: 13px; font-weight: 600; color: var(--krim-2); }
.k-isi { font-size: 15px; 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: 2px 8px; border-radius: 999px; background: var(--isian); color: var(--kuning); }
.k-gagal { color: var(--bata-terang); }
.komen-tulis { display: flex; gap: 8px; padding: 8px 12px; border-top: .5px solid var(--garis); flex: none; align-items: flex-end; }
.komen-tulis textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px; border-radius: 20px; border: 0;
  background: var(--isian); color: var(--krim); padding: 10px 12px; font: inherit; font-size: 16px; outline: none;
}
.btn-utama { min-height: 40px; padding: 0 16px; border-radius: 20px; background: var(--aksen); color: #fff; font-weight: 600; font-size: 16px; }
.btn-utama:disabled { opacity: .35; }
.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: 50px; border-radius: 12px; border: 0; background: var(--isian); color: var(--krim);
  padding: 0 14px; font: inherit; font-size: 16px; outline: none;
}
.borang input:focus { box-shadow: 0 0 0 2px var(--aksen); }
.borang .btn-utama { height: 50px; border-radius: 14px; font-size: 17px; }
.btn-google { height: 50px; border-radius: 14px; 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(--aksen); 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: 14px; border-radius: 14px; background: var(--isian); color: var(--aksen); text-decoration: none; font-weight: 600; font-size: 16px; }
.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(--bahan); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); color: var(--krim);
  padding: 12px 18px; border-radius: 999px; font-weight: 500; font-size: 15px; box-shadow: 0 8px 30px rgba(0,0,0,.35); max-width: calc(100vw - 32px);
}

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