:root {
  --bg: #fbf6f3;
  --card: #ffffff;
  --text: #3d2f33;
  --muted: #9a868b;
  --rose: #c97b84;
  --rose-soft: #f6e3e5;
  --sage: #8fae9b;
  --sage-soft: #e5efe8;
  --line: #efe4e1;
  --shadow: 0 2px 12px rgba(120, 70, 80, .07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1719;
    --card: #2a2225;
    --text: #f3e9eb;
    --muted: #a8969a;
    --rose: #e09aa2;
    --rose-soft: #4a3135;
    --sage: #9fc2ac;
    --sage-soft: #2f3d34;
    --line: #3a2f32;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
h2 { font-size: 1rem; margin: 0 0 12px; }
p { margin: 0; }
small, .muted { color: var(--muted); font-size: .82rem; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* Header */
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
}
.greet { font-weight: 700; font-size: 1.15rem; }
.hijri { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.icon-btn { font-size: 1.3rem; width: 40px; height: 40px; border-radius: 12px; }
.icon-btn:active { background: var(--rose-soft); }

main { padding: 0 16px; }
.tab { display: none; }
.tab.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card {
  background: var(--card); border-radius: 20px; padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.center { text-align: center; }

.date-nav { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.banner { border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; font-size: .9rem; line-height: 1.45; }
.banner.haid { background: var(--rose-soft); }
.banner.warn { background: #fdf0d8; color: #6b4a12; text-align: left; margin-top: 12px; }

.streak { background: var(--sage-soft); color: var(--sage); font-weight: 600; font-size: .8rem; padding: 4px 10px; border-radius: 99px; }

/* Ring progres sholat */
.ring-wrap { position: relative; width: 130px; height: 130px; margin: 4px auto 14px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--rose); stroke-linecap: round; stroke-dasharray: 326.7; transition: stroke-dashoffset .4s; }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text b { font-size: 1.6rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  flex: 1 1 auto; padding: 10px 12px; border-radius: 14px;
  background: var(--bg); border: 1.5px solid var(--line); font-weight: 600; font-size: .9rem;
}
.chips button.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.chips button:disabled { opacity: .4; text-decoration: line-through; }
.center-chips { justify-content: center; margin: 8px 0 20px; }
.center-chips button { flex: 0 1 auto; }

/* List amalan / riwayat */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; }
.check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-content: center; color: #fff; font-size: .8rem; }
.item.on .check { background: var(--sage); border-color: var(--sage); }
.item:disabled { opacity: .4; }
.del { color: var(--muted); padding: 4px 8px; }

.stepper { display: flex; justify-content: center; align-items: center; gap: 28px; text-align: center; margin: 6px 0 14px; }
.stepper b { display: block; font-size: 2rem; }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--rose-soft); color: var(--rose); font-size: 1.5rem; font-weight: 700; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.bar div { height: 100%; background: var(--sage); width: 0; transition: width .4s; }

.big { font-size: 3.2rem; font-weight: 800; color: var(--rose); margin: 4px 0; }
.btn {
  display: block; width: 100%; padding: 13px; border-radius: 14px; margin-top: 12px;
  background: var(--rose); color: #fff; font-weight: 600; text-align: center;
}
.btn.ghost { background: var(--rose-soft); color: var(--rose); }
.btn:active { transform: scale(.98); }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }

.form-row { display: flex; gap: 8px; margin-top: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); flex: 1; margin-top: 10px; }
input {
  font: inherit; color: var(--text); background: var(--bg); padding: 10px;
  border: 1.5px solid var(--line); border-radius: 12px; width: 100%;
}
.file-btn { flex-direction: row; justify-content: center; font-size: 1rem; color: var(--rose); }

/* Tasbih */
.tasbih {
  display: grid; place-content: center; gap: 4px;
  width: 260px; height: 260px; margin: 0 auto 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--rose-soft), var(--card));
  box-shadow: 0 10px 40px rgba(201, 123, 132, .25), inset 0 0 0 6px var(--rose-soft);
  user-select: none;
}
.tasbih:active { transform: scale(.97); }
.tasbih b { font-size: 4rem; color: var(--rose); line-height: 1; }
.arab { font-size: 1.4rem; }
.tasbih.done { box-shadow: 0 10px 40px rgba(143, 174, 155, .45), inset 0 0 0 6px var(--sage); }

/* Bottom nav */
.bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); padding: 6px 0; border-radius: 12px; }
.bottom button span { font-size: 1.3rem; filter: grayscale(1); opacity: .6; }
.bottom button.active { color: var(--rose); font-weight: 600; }
.bottom button.active span { filter: none; opacity: 1; }

dialog {
  border: 0; border-radius: 22px; padding: 20px; width: min(420px, calc(100% - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(40, 20, 25, .4); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0 10px; }

/* Jadwal sholat */
.loc-btn { font-size: .8rem; color: var(--rose); font-weight: 600; padding: 4px 0; }
.next { text-align: center; margin: 6px 0 14px; display: flex; flex-direction: column; gap: 2px; }
.next b { font-size: 1.5rem; color: var(--rose); }
.next .hint { color: var(--rose); font-size: .8rem; text-decoration: underline; margin-top: 6px; }
.jadwal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.jadwal div { padding: 8px 0; border-radius: 12px; display: flex; flex-direction: column; gap: 2px; }
.jadwal small { font-size: .66rem; }
.jadwal b { font-size: .8rem; font-variant-numeric: tabular-nums; }
.jadwal .minor b { font-weight: 500; color: var(--muted); }
.jadwal .now { background: var(--rose); color: #fff; }
.jadwal .now small { color: #fff; }
.chips button small { display: block; font-weight: 400; font-size: .72rem; opacity: .75; margin-top: 2px; color: inherit; }

/* Rutinitas */
.mini { width: 34px; height: 34px; border-radius: 10px; background: var(--rose-soft); color: var(--rose); font-weight: 700; font-size: 1.1rem; }
.mini:disabled, .item.off { opacity: .45; }
.item.on .grow small { color: var(--sage); }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-top: 12px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--rose); box-shadow: var(--shadow); }
.chips.ideas button, .chips.days button { flex: 0 1 auto; padding: 7px 10px; font-size: .82rem; font-weight: 500; }
.chips.days button { flex: 1; padding: 8px 0; }
.emoji-field { flex: 0 0 72px; }
.emoji-field input { text-align: center; font-size: 1.2rem; padding: 7px; }
.check-row { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .9rem; }
.check-row input { width: 20px; height: 20px; accent-color: var(--rose); }
select { font: inherit; color: var(--text); background: var(--bg); padding: 10px; border: 1.5px solid var(--line); border-radius: 12px; width: 100%; }
h3 { font-size: .95rem; margin: 0 0 6px; }
dialog { max-height: 88vh; overflow-y: auto; }
.streak:empty { display: none; }

/* ===== iPhone / layar kecil ===== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); overflow-x: hidden; }
body { overflow-x: hidden; min-height: 100dvh; }
/* Font input minimal 16px: kalau lebih kecil, iPhone nge-zoom otomatis saat diketuk */
input, select, textarea { font-size: 16px; min-width: 0; }
input[type="date"] {
  -webkit-appearance: none; appearance: none;
  display: block; min-height: 46px; line-height: 1.4; text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
label, .form-row > *, .grow, .chips button { min-width: 0; }
.grow { overflow-wrap: anywhere; }
.top > div { min-width: 0; }
/* Hilangkan zoom dobel-tap & delay ketukan di iOS */
button, label, a { touch-action: manipulation; }
.jadwal { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.tasbih { width: min(260px, 72vw); height: min(260px, 72vw); }
dialog {
  max-height: 85vh; max-height: 85dvh;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

@media (max-width: 360px) {
  main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px 12px; border-radius: 18px; }
  .jadwal { gap: 2px; }
  .jadwal small { font-size: .58rem; }
  .jadwal b { font-size: .7rem; }
  .chips button { padding: 9px 8px; font-size: .85rem; }
  .big { font-size: 2.6rem; }
  .stepper { gap: 18px; }
  .bottom button { font-size: .66rem; }
}

/* Banner pasang app */
.install-banner { background: var(--card); border: 1.5px dashed var(--rose); border-radius: 18px; padding: 14px; margin-bottom: 12px; position: relative; }
.install-banner h2 { margin-bottom: 8px; padding-right: 28px; }
.install-banner ol { margin: 0; padding-left: 20px; font-size: .9rem; line-height: 1.6; }
.install-banner .close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; color: var(--muted); font-size: 1rem; }
.share-ico { display: inline-block; vertical-align: -3px; width: 16px; height: 16px; }

/* Backup */
.code-box { background: var(--rose-soft); border-radius: 14px; padding: 12px; text-align: center; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.code-box span { font-size: .78rem; color: var(--muted); }
.code-box b { font-family: ui-monospace, Menlo, monospace; font-size: 1.15rem; letter-spacing: .06em; color: var(--rose); user-select: all; -webkit-user-select: all; }
details.restore { margin-top: 12px; }
details.restore summary { color: var(--rose); font-weight: 600; font-size: .9rem; cursor: pointer; padding: 6px 0; }
#restoreCode { font-family: ui-monospace, Menlo, monospace; letter-spacing: .05em; text-transform: uppercase; }
