:root {
  --kertas: #f4ece1;
  --kertas2: #ebe0d1;
  --kopi: #2b1f19;
  --kopi2: #4a3a30;
  --kelabu: #8a7b70;
  --oren: #e2672e;
  --oren2: #c4521f;
  --putih: #fffdf9;
  --gelap: #14100d;
  --jejari: 14px;
  --bayang: 0 6px 22px rgba(43, 31, 25, .14);
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tulis: "Caveat", "Comic Sans MS", cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.5 var(--sans);
  color: var(--kopi);
  background: var(--kertas);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; }
[hidden] { display: none !important; }

#demoBar {
  position: fixed; inset: 0 0 auto 0; z-index: 50; margin: 0;
  padding: 4px 10px; text-align: center; font-size: 12px; letter-spacing: .02em;
  background: var(--kopi); color: #f3d9c4;
}
body[data-skrin="kamera"] #demoBar, body[data-skrin="wall"] #demoBar { display: none; }

/* ---------- skrin ---------- */
.skrin { display: none; min-height: 100%; }
.skrin.aktif { display: block; }
.isi { max-width: 460px; margin: 0 auto; padding: 44px 20px 40px; }
.isi.lebar { max-width: 980px; }
.kecil { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--kelabu); margin: 0; }
.nama { font-family: var(--serif); font-size: 44px; line-height: 1.05; letter-spacing: -.01em; }
.nama em { font-style: italic; font-weight: 400; color: var(--oren); }
.ruang { width: 40px; }

.hero { text-align: center; padding: 26px 0 18px; }
.hero .nama { margin: 10px 0 8px; font-size: 52px; }
.tarikh { margin: 0; color: var(--kopi2); }

.kaunter { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 22px; }
.kaunter div { background: var(--putih); border-radius: var(--jejari); padding: 12px 14px; box-shadow: var(--bayang); text-align: center; }
.kaunter b { display: block; font: 600 30px/1.1 var(--serif); color: var(--oren2); }
.kaunter span { font-size: 13px; color: var(--kelabu); }

.medan { display: block; font-size: 14px; font-weight: 500; margin-bottom: 14px; }
.medan input, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  border: 1.5px solid #d8c9b8; border-radius: 12px; background: var(--putih); outline: none;
}
.medan input:focus, textarea:focus { border-color: var(--oren); }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--kopi); background: transparent; font-weight: 500; font-size: 15px;
  text-decoration: none; text-align: center; color: var(--kopi);
}
.btn.utama { background: var(--oren); border-color: var(--oren); color: #fff; }
.btn.utama:active { background: var(--oren2); }
.btn.besar { width: 100%; min-height: 56px; font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.btn:disabled { opacity: .45; }
.dua { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.langkah { margin: 26px 0 18px; padding: 0; list-style: none; counter-reset: l; }
.langkah li { counter-increment: l; position: relative; padding: 0 0 12px 40px; color: var(--kopi2); font-size: 15px; }
.langkah li::before {
  content: counter(l); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 600 14px var(--serif); background: var(--kertas2); color: var(--oren2);
}
.pautan { display: block; text-align: center; color: var(--oren2); font-weight: 500; }

.qrPc { display: none; }
@media (min-width: 900px) {
  #s-utama.aktif { display: flex; justify-content: center; align-items: center; gap: 60px; }
  #s-utama .isi { margin: 0; }
  .qrPc { display: block; text-align: center; background: var(--putih); padding: 22px; border-radius: 20px; box-shadow: var(--bayang); }
  .qrPc img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
  .qrPc p { margin: 10px 0 0; font-weight: 500; }
}

/* ---------- kamera ---------- */
.gelap { background: var(--gelap); color: #f3e7da; }
#s-kamera.aktif { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.atas { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.atas.terang { padding: 0 0 6px; }
.atas h2 { font-size: 18px; }
.ikonBtn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .12); font-size: 22px; line-height: 1; display: grid; place-items: center;
}
.terang .ikonBtn { background: var(--kertas2); }
.baki { font-size: 14px; letter-spacing: .04em; }
.baki b { font: 600 20px var(--serif); color: #ffb27e; }

.pemidang { position: relative; flex: 1; min-height: 0; margin: 0 12px; border-radius: 18px; overflow: hidden; background: #000; }
.pemidang video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pemidang video.cermin { transform: scaleX(-1); }
.vinyet { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0, 0, 0, .55); }
.kilat { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.kilat.jalan { animation: kilat .45s ease-out; }
@keyframes kilat { from { opacity: .95; } to { opacity: 0; } }
.ralatKamera { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.ralatKamera p { margin: 0; max-width: 300px; }

.filterBar { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 4px; scrollbar-width: none; }
.filterBar::-webkit-scrollbar { display: none; }
.filterBar button {
  flex: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06);
}
.filterBar button.aktif { background: #f3e7da; color: var(--kopi); border-color: #f3e7da; font-weight: 700; }

.bawah { display: flex; align-items: center; justify-content: space-between; padding: 12px 28px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.thumb { width: 48px; height: 48px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .7); background: #2a221d center/cover; cursor: pointer; }
.bawah .ruang { width: 48px; }
.shutter {
  width: 78px; height: 78px; border-radius: 50%; cursor: pointer;
  border: 5px solid #f3e7da; background: var(--oren); box-shadow: 0 0 0 3px var(--gelap) inset;
  transition: transform .08s;
}
.shutter:active { transform: scale(.92); }
.shutter:disabled { background: #5a4c43; }

/* ---------- polaroid ---------- */
.polaroid { margin: 0; background: var(--putih); padding: 10px 10px 12px; border-radius: 4px; box-shadow: var(--bayang); }
.polaroid img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #ddd2c4; border-radius: 2px; }
.polaroid figcaption { padding: 8px 2px 0; min-height: 26px; }
.tulisan { display: block; font: 600 21px/1.15 var(--tulis); color: var(--kopi); }
.polaroid small, .kadUcapan small { display: block; color: var(--kelabu); font-size: 12px; margin-top: 4px; }

/* ---------- lapisan (semak & lihat besar) ---------- */
.lapisan {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; background: rgba(20, 16, 13, .88); overflow-y: auto;
}
.kadSemak { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.polaroid.besar { width: 100%; max-width: 380px; }
.polaroid.besar img { aspect-ratio: auto; max-height: 62vh; object-fit: contain; }
.polaroid.besar img:not([src]) { aspect-ratio: 3 / 4; max-height: 52vh; background: #2a221d; }
#statusCuci { font: 600 22px var(--tulis); text-align: center; color: var(--kopi2); }
.cuci { animation: cuci 2.6s ease-out both; }
@keyframes cuci {
  0% { filter: brightness(.15) sepia(1) blur(8px); }
  60% { filter: brightness(.8) sepia(.5) blur(2px); }
  100% { filter: none; }
}
#semak textarea { margin: 0; }
#semak .btn:not(.utama), #kotak .btn:not(.utama) { color: #f3e7da; border-color: #f3e7da; }
#kotak .dua { width: 100%; max-width: 380px; }

/* ---------- ucapan ---------- */
.tab2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--kertas2); border-radius: 999px; padding: 4px; margin: 16px 0; }
.tab2 button { border: 0; background: transparent; padding: 10px; border-radius: 999px; cursor: pointer; font-weight: 500; }
.tab2 button.aktif { background: var(--putih); box-shadow: var(--bayang); }
#modTeks textarea { margin-bottom: 14px; }
#modSuara { text-align: center; padding: 10px 0 16px; }
.rakam {
  width: 150px; height: 150px; border-radius: 50%; border: 0; cursor: pointer; font-weight: 700;
  background: var(--putih); box-shadow: var(--bayang), 0 0 0 8px var(--kertas2); color: var(--oren2);
}
.rakam.jalan { background: var(--oren); color: #fff; animation: denyut 1.2s ease-in-out infinite; }
@keyframes denyut { 50% { box-shadow: var(--bayang), 0 0 0 16px rgba(226, 103, 46, .25); } }
.masaRakam { font-variant-numeric: tabular-nums; color: var(--kelabu); }
#mainSuara { width: 100%; }

/* ---------- galeri ---------- */
.galHead { text-align: center; padding: 6px 0 18px; }
.galHead .nama { margin: 6px 0; }
.galHead p#galStat { margin: 0 0 14px; color: var(--kopi2); }
.galHead .dua { max-width: 420px; margin: 0 auto; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; scrollbar-width: none; }
.chips button {
  flex: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid #d8c9b8; background: var(--putih);
}
.chips button.aktif { background: var(--kopi); color: var(--kertas); border-color: var(--kopi); }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: start; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.grid .polaroid { cursor: zoom-in; }
.grid .polaroid:nth-child(3n+1) { transform: rotate(-.8deg); }
.grid .polaroid:nth-child(3n+2) { transform: rotate(.6deg); }
.kadUcapan { background: var(--putih); border-radius: var(--jejari); padding: 14px; box-shadow: var(--bayang); border-left: 4px solid var(--oren); }
.kadUcapan p { margin: 0; font: 600 21px/1.2 var(--tulis); white-space: pre-wrap; overflow-wrap: anywhere; }
.kadUcapan b { display: block; margin-bottom: 8px; }
.kadUcapan audio { width: 100%; height: 40px; }
.kosong { text-align: center; color: var(--kelabu); padding: 30px 0; }

/* ---------- live wall ---------- */
.wall { background: #0d0a08; color: #f3e7da; }
#s-wall.aktif { position: fixed; inset: 0; z-index: 30; overflow: hidden; }
.wallLapis {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 4vh 22vw 4vh 4vw; opacity: 0; transition: opacity 1.2s ease;
}
.wallLapis.nampak { opacity: 1; }
.wallLapis .polaroid { max-height: 92vh; display: flex; flex-direction: column; transform: rotate(-1.2deg); }
.wallLapis .polaroid img { max-height: 76vh; width: auto; max-width: 100%; aspect-ratio: auto; }
.wallLapis .tulisan { font-size: clamp(22px, 3vw, 40px); }
.wallLapis .kadUcapan { max-width: 60vw; padding: 5vh 4vw; }
.wallLapis .kadUcapan p { font-size: clamp(30px, 4.4vw, 64px); }
.wallLapis .kadUcapan small { font-size: clamp(14px, 1.6vw, 22px); color: var(--kopi2); }
.wallInfo { position: absolute; right: 3vw; bottom: 5vh; width: 17vw; min-width: 150px; text-align: center; }
.wallInfo .nama { font-size: clamp(26px, 2.6vw, 44px); margin: 0 0 14px; text-transform: none; letter-spacing: 0; }
.wallInfo img { width: 100%; max-width: 200px; height: auto; background: #fff; padding: 8px; border-radius: 10px; image-rendering: pixelated; }
.wallInfo p { margin: 8px 0 0; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
.tutupWall {
  position: absolute; top: 14px; right: 14px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .3);
  color: #f3e7da; padding: 6px 14px; border-radius: 999px; cursor: pointer; opacity: .5;
}
.tutupWall:hover { opacity: 1; }
@media (max-width: 700px) {
  .wallLapis { padding: 4vh 4vw 30vh; }
  .wallInfo { left: 0; right: 0; bottom: 3vh; width: auto; display: flex; align-items: center; justify-content: center; gap: 12px; }
  .wallInfo .nama { display: none; }
  .wallInfo img { width: 90px; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; margin: 0; transform: translate(-50%, 20px);
  max-width: calc(100% - 40px); padding: 10px 18px; border-radius: 999px; background: var(--kopi); color: #fff;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
#toast.nampak { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .cuci, .kilat.jalan, .rakam.jalan { animation: none; }
  .wallLapis { transition: none; }
}

/* ---------- galeri awan ---------- */
#demoBar { transition: background .3s; }
#demoBar.amaran { background: var(--oren); color: #fff; }
.polaroid, .kadUcapan { position: relative; }
.lencana {
  position: absolute; top: 6px; right: 6px; z-index: 2; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; background: rgba(43, 31, 25, .82); color: #fff;
}
.lencana.menunggu { background: var(--oren); }
.lencana.ditolak { background: #9b2c2c; }
.kadUcapan .lencana { top: 8px; right: 8px; }
.btn.dengar { width: 100%; min-height: 40px; font-size: 14px; margin: 2px 0; }
#muatLagi { display: flex; margin: 20px auto 0; min-width: 160px; }
.kunciBox { margin: 28px auto 0; max-width: 420px; background: var(--putih); border-radius: var(--jejari); padding: 12px 16px; box-shadow: var(--bayang); }
.kunciBox summary { cursor: pointer; font-weight: 500; color: var(--kopi2); }
.kunciBox p { margin: 10px 0; font-size: 14px; color: var(--kelabu); }
.barisKunci { display: flex; gap: 8px; }
.barisKunci input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1.5px solid #d8c9b8; border-radius: 12px; background: var(--putih);
  font: 500 16px var(--sans); letter-spacing: .08em; text-transform: uppercase; outline: none;
}
.barisKunci input:focus { border-color: var(--oren); }
.butangTeks { background: none; border: 0; padding: 12px; margin: 14px auto 0; cursor: pointer; font: inherit; }
.butangTeks.padam { color: #b23a3a; font-size: 14px; }