/* Gaya seluruh halaman Digital Memory.
   Warna utama bisa diganti per album lewat variabel --accent (diatur oleh JavaScript). */

:root {
  --accent: #e8a0b4;
  --accent-dark: #c9728c;
  --accent-soft: #fbe9ee;
  --bg: #fbf7f4;
  --card: #ffffff;
  --ink: #2b2430;
  --muted: #7a7280;
  --line: #ece2df;
  --ok: #3f9b6e;
  --danger: #d2495a;
  --warn: #d98a1f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(43, 36, 48, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 10px; }
a { color: var(--accent-dark); }
img, canvas, video { max-width: 100%; }
[hidden], .hidden { display: none !important; }

/* ---------- tata letak ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 90px; }
.container-narrow { max-width: 520px; margin: 0 auto; padding: 20px 16px 90px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mt { margin-top: 16px; }

/* ---------- bilah atas ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: Georgia, serif; font-size: 1.25rem; font-weight: bold; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent-dark); }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.btn-primary, .topbar nav a.btn-primary:hover { color: #fff; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 10px 16px; border-radius: 999px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: transform 0.05s, background 0.15s;
}
.btn:hover { background: #f6efec; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-primary:hover { background: #b9627c; }
.btn-danger { color: var(--danger); border-color: #f1c6cc; }
.btn-danger:hover { background: #fdecee; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { display: flex; width: 100%; }

/* ---------- kartu ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }

/* ---------- formulir ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.82rem; }
input[type='text'], input[type='email'], input[type='password'], input[type='date'], input[type='number'], textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
input[type='color'] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 0.92rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent-dark); }

/* pilihan Publik / Privat */
.segmented { display: flex; gap: 8px; }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 10px 8px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font-weight: 600; font-size: 0.92rem;
}
.segmented input:checked + span { background: var(--accent-soft); border-color: var(--accent-dark); color: var(--accent-dark); }

/* ---------- pesan ---------- */
.alert { padding: 11px 14px; border-radius: 10px; font-size: 0.92rem; }
.alert-error { background: #fdecee; color: #9c2a38; border: 1px solid #f1c6cc; }
.alert-ok { background: #e9f6ef; color: #26704d; border: 1px solid #bfe3cf; }
.alert-info { background: var(--accent-soft); color: #86415a; border: 1px solid #f3cdd9; }

#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 0.92rem; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 100; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* ---------- tab, chip, badge ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 14px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent-dark); }
.tab .count { background: var(--accent-soft); color: var(--accent-dark); border-radius: 999px; padding: 1px 8px; font-size: 0.78rem; margin-left: 4px; }

.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.88rem; cursor: pointer; }
.chip.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 700; background: #eee; color: #555; }
.badge-private { background: #efe7fa; color: #5b3f8f; }
.badge-public { background: #e3f3ea; color: #26704d; }
.badge-warn { background: #fdf0da; color: #9a6210; }

/* ---------- galeri foto ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }

.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #eee; cursor: pointer; border: none; padding: 0; display: block; width: 100%; }
.photo img, .photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .tag { position: absolute; top: 6px; left: 6px; }
.photo .by {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; color: #fff; font-size: 0.78rem; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.photo .lock {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: #fff; background: rgba(43, 36, 48, 0.35); font-size: 0.85rem; font-weight: 600; text-align: center; padding: 8px;
}
.photo .lock .big { font-size: 1.6rem; }
.photo .play { position: absolute; right: 8px; top: 8px; background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 0.75rem; }

/* ---------- tombol unggah melayang (halaman tamu) ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.bottombar .inner { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.bottombar .btn { flex: 1; }

/* bilah batal 3 detik setelah unggah */
.undo-bar {
  position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 60; max-width: 496px; margin: 0 auto;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 14px; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.undo-bar button { background: none; border: none; color: #ffd3de; font: inherit; font-weight: 700; cursor: pointer; }
.undo-bar .undo-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 100%; transform-origin: left; animation: undo 3s linear forwards; }
@keyframes undo { to { transform: scaleX(0); } }

/* ---------- jendela (modal) dan lightbox ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(20, 15, 25, 0.72); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal { align-items: center; padding: 20px; } }
.modal-box {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 18px; position: relative;
}
@media (min-width: 640px) { .modal-box { border-radius: 20px; } }
.modal-box.wide { max-width: 860px; }
.modal-close { position: absolute; top: 10px; right: 12px; background: #f2ebe8; border: none; border-radius: 999px; width: 34px; height: 34px; font-size: 1.2rem; cursor: pointer; }
.lightbox-img { width: 100%; max-height: 62vh; object-fit: contain; background: #111; border-radius: 12px; display: block; }

/* ---------- daftar, pesan, statistik ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.list-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.message { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; }
.message img.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; }
.message .who { font-weight: 700; font-size: 0.92rem; }
.message audio { width: 100%; max-width: 280px; height: 36px; margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--accent-soft); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; font-family: Georgia, serif; }
.stat span { font-size: 0.8rem; color: var(--muted); }

.progress { height: 8px; background: #eee; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent-dark); width: 0; transition: width 0.2s; }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; border: 2px dashed var(--line); border-radius: var(--radius); }

/* ---------- halaman depan ---------- */
.hero { text-align: center; padding: 48px 16px 28px; max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 2.3rem; }
.hero p { color: var(--muted); font-size: 1.05rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 10px; }
.feature { padding: 18px; }
.feature .ico { font-size: 1.6rem; }

/* ---------- dashboard dan detail album ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.album-card { overflow: hidden; display: flex; flex-direction: column; }
.album-card .color-strip { height: 8px; background: var(--accent); }
.album-card .body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.qr-box img { width: 220px; height: 220px; }
.url-box { word-break: break-all; font-size: 0.85rem; background: #f6efec; border-radius: 8px; padding: 8px 10px; }

.plan-card { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; flex: 1; min-width: 200px; }
.plan-card.current { border-color: var(--accent-dark); background: var(--accent-soft); }

/* ---------- template dan kolase ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.tpl { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; padding: 0; text-align: center; font: inherit; }
.tpl.active { border-color: var(--accent-dark); }
.tpl canvas, .tpl img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: #eee; }
.tpl span { display: block; padding: 6px; font-size: 0.8rem; font-weight: 600; }

.studio-preview { display: flex; justify-content: center; background: #f2ebe8; border-radius: 12px; padding: 10px; }
.studio-preview canvas { max-height: 60vh; width: auto; height: auto; border-radius: 6px; box-shadow: var(--shadow); touch-action: none; }
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 220px; overflow: auto; }
.pick-grid .pick { position: relative; aspect-ratio: 1; border: 3px solid transparent; border-radius: 8px; overflow: hidden; padding: 0; background: #eee; cursor: pointer; }
.pick-grid .pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-grid .pick.on { border-color: var(--accent-dark); }
.pick-grid .pick .n { position: absolute; top: 3px; right: 3px; background: var(--accent-dark); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent-dark); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 24px 16px; }

input[type='file'] {
  width: 100%; padding: 8px 10px; border: 1.5px dashed var(--line); border-radius: 12px;
  background: var(--bg); color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer;
}
input[type='file']:hover { border-color: var(--accent-dark); }
input[type='file']::file-selector-button {
  margin-right: 12px; padding: 7px 14px; border: 1px solid var(--accent-dark); border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-dark); font: inherit; font-weight: 600; font-size: 0.86rem; cursor: pointer;
}
input[type='file']::file-selector-button:hover { background: var(--accent-dark); color: #fff; }

.tpl-editor-grid { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 720px) { .tpl-editor-grid { grid-template-columns: 1fr; } }
.tpl-stage { position: relative; width: 100%; max-width: 340px; aspect-ratio: 4 / 5; margin: 0 auto; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: repeating-conic-gradient(#f3eef0 0% 25%, #fff 0% 50%) 50% / 16px 16px; user-select: none; touch-action: none; }
.tpl-controls { display: flex; flex-direction: column; gap: 12px; }
.tpl-panel { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }