@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@400;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg: #F3F1FF;
  --bg-deep: #ECE8FF;
  --surface: #FFFFFF;
  --ink: #241E46;
  --ink-soft: #6B6489;
  --primary: #6C5CE7;
  --primary-dark: #4C3FC7;
  --primary-tint: #E6E1FF;
  --gold: #FFC93C;
  --coral: #FF6B6B;
  --coral-tint: #FFE3E3;
  --teal: #2EC4B6;
  --teal-tint: #DCFAF6;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-soft: 0 10px 30px rgba(36, 30, 70, 0.10);
  --shadow-pop: 0 14px 34px rgba(108, 92, 231, 0.28);
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, var(--bg-deep) 0%, transparent 42%),
    radial-gradient(circle at 92% 18%, #E1F8F4 0%, transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 40px; }

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline-offset: 3px;
}
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--primary-dark);
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; }

.app-shell { max-width: 920px; margin: 0 auto; padding: 18px 16px 60px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px 22px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 14px;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: var(--shadow-pop);
}
.brand-text { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: 0.2px; }
.brand-text small { display: block; font-family: var(--font-body); font-weight: 700; font-size: 11px; color: var(--ink-soft); letter-spacing: 0.4px; text-transform: uppercase; }

.pill-btn {
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 13px;
  padding: 9px 16px; border-radius: 999px; box-shadow: var(--shadow-soft);
  display: inline-flex; align-items: center; gap: 6px; transition: transform .15s ease;
}
.pill-btn:hover { transform: translateY(-1px); }
.pill-btn.primary { background: var(--primary); color: #fff; }
.pill-btn.ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.pill-btn.danger { background: var(--coral); color: #fff; }
.pill-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Views ---------- */
.view { display: none; animation: fadeUp .35s ease; }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }
@media (prefers-reduced-motion: reduce) {
  .view, * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---------- Kid selector (home) ---------- */
.hero-copy { text-align: center; margin: 6px 0 26px; }
.hero-copy h1 { font-size: 30px; }
.hero-copy p { color: var(--ink-soft); font-weight: 700; margin-top: 6px; }

.kid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .kid-grid { grid-template-columns: 1fr; } }

.kid-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px;
  box-shadow: var(--shadow-soft); text-align: center; position: relative; overflow: hidden;
  border: 3px solid transparent; transition: transform .18s ease, border-color .18s ease;
}
.kid-card:hover { transform: translateY(-4px); border-color: var(--kid-color, var(--primary)); }
.kid-card .avatar-ring { width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 50%;
  background: color-mix(in srgb, var(--kid-color, var(--primary)) 18%, white);
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.kid-card .avatar-ring img { width: 100%; height: 100%; object-fit: cover; }
.kid-card h3 { font-size: 22px; }
.kid-card .kid-meta { color: var(--ink-soft); font-weight: 700; font-size: 13px; margin: 4px 0 14px; }
.kid-card .cta { width: 100%; background: var(--kid-color, var(--primary)); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 15px; padding: 12px; border-radius: var(--radius-sm); }

.parent-link { text-align: center; margin-top: 28px; }
.parent-link button { background: none; box-shadow: none; color: var(--ink-soft); font-weight: 700; font-size: 13px; text-decoration: underline; }

/* ---------- Dashboard ---------- */
.dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dash-who { display: flex; align-items: center; gap: 12px; }
.dash-who .avatar-sm { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: var(--primary-tint); display:flex; align-items:center; justify-content:center; font-size: 22px; }
.dash-who .avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.dash-who h2 { font-size: 20px; }
.dash-who .stage-label { font-size: 12px; font-weight: 800; color: var(--primary-dark); text-transform: uppercase; letter-spacing: .4px; }

.companion-card {
  background: linear-gradient(160deg, var(--surface), var(--primary-tint) 140%);
  border-radius: var(--radius-lg); padding: 26px 22px; box-shadow: var(--shadow-soft);
  display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: center; margin-bottom: 20px;
}
@media (max-width: 560px) { .companion-card { grid-template-columns: 1fr; text-align: center; } }
.companion-stage { display: flex; align-items: center; justify-content: center; }
.companion-stage svg { width: 140px; height: 140px; filter: drop-shadow(0 10px 16px rgba(108,92,231,.25)); }

.xp-row { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.xp-bar { height: 12px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.xp-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--teal)); border-radius: 999px; transition: width .5s ease; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.stat-box { background: rgba(255,255,255,.6); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-box .num { font-family: var(--font-mono); font-weight: 700; font-size: 18px; }
.stat-box .lbl { font-size: 11px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { flex: none; background: var(--surface); font-weight: 700; font-size: 13.5px; padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-soft); color: var(--ink-soft); white-space: nowrap; }
.tab-btn.active { background: var(--primary); color: #fff; }

/* ---------- Quest cards ---------- */
.quest-list { display: grid; gap: 12px; }
.quest-card {
  background: var(--surface); border-radius: var(--radius-md); padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-soft); border-left: 6px solid var(--teal);
}
.quest-card.negative { border-left-color: var(--coral); }
.quest-card .qname { font-weight: 800; font-size: 15px; }
.quest-card .qpoints { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--teal); }
.quest-card.negative .qpoints { color: var(--coral); }
.quest-card .qbtn { background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; padding: 9px 16px; border-radius: 999px; flex: none; }
.quest-card .qbtn.done { background: var(--bg-deep); color: var(--ink-soft); }
.quest-card .qbtn:disabled { opacity: .6; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--ink-soft); font-weight: 700; }

/* ---------- Log list (history / approvals) ---------- */
.log-list { display: grid; gap: 10px; }
.log-item { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: var(--shadow-soft); }
.log-item .li-main { display: flex; flex-direction: column; }
.log-item .li-name { font-weight: 800; font-size: 14px; }
.log-item .li-meta { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
.log-item .li-points { font-family: var(--font-mono); font-weight: 700; }
.log-item.approved .li-points { color: var(--teal); }
.log-item.rejected .li-points { color: var(--coral); text-decoration: line-through; }
.log-item.pending .li-points { color: var(--gold); }
.badge { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.badge.pending { background: #FFF3D6; color: #9A6B00; }
.badge.approved { background: var(--teal-tint); color: #0E7C6E; }
.badge.rejected { background: var(--coral-tint); color: #B3312C; }
.li-actions { display: flex; gap: 6px; }
.li-actions button { font-size: 12px; padding: 7px 12px; border-radius: 999px; font-weight: 800; }
.btn-approve { background: var(--teal); color: #fff; }
.btn-reject { background: var(--coral); color: #fff; }

/* ---------- Cards / sections ---------- */
.section-card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-soft); margin-bottom: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title h3 { font-size: 17px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 800; color: var(--ink-soft); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 2px solid var(--bg-deep);
  background: var(--bg); font-family: var(--font-body); font-size: 14.5px; font-weight: 700; color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--primary); outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Parent login ---------- */
.pin-card { max-width: 340px; margin: 60px auto; background: var(--surface); border-radius: var(--radius-lg); padding: 30px 26px; box-shadow: var(--shadow-soft); text-align: center; }
.pin-card h2 { margin-bottom: 6px; }
.pin-card p { color: var(--ink-soft); font-weight: 700; font-size: 13.5px; margin-bottom: 20px; }
.pin-dots { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-deep); transition: background .15s; }
.pin-dots span.filled { background: var(--primary); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { background: var(--bg); border-radius: var(--radius-sm); padding: 16px 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.pin-pad button:active { background: var(--primary-tint); }
.pin-error { color: var(--coral); font-weight: 800; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- Parent shell ---------- */
.parent-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; }
.parent-tabs .tab-btn { font-size: 13px; }

.activity-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bg-deep); }
.activity-row:last-child { border-bottom: none; }
.activity-row .ar-name { font-weight: 800; font-size: 14px; }
.activity-row .ar-meta { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; }
.icon-btn { background: var(--bg); width: 32px; height: 32px; border-radius: 50%; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.danger { color: var(--coral); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 700; font-size: 13.5px; padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow-pop); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.avatar-upload { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-upload .avatar-ring { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: var(--primary-tint); display:flex; align-items:center; justify-content:center; font-size: 26px; }
.avatar-upload .avatar-ring img { width: 100%; height: 100%; object-fit: cover; }

.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti-piece { position: absolute; top: -10px; width: 8px; height: 14px; border-radius: 2px; animation: confetti-fall 1.1s ease-in forwards; }
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(340deg); opacity: .3; } }

.muted { color: var(--ink-soft); font-weight: 700; font-size: 13px; }
.type-toggle { display: flex; gap: 8px; }
.type-toggle button { flex: 1; padding: 10px; border-radius: var(--radius-sm); background: var(--bg); font-weight: 800; }
.type-toggle button.active.pos { background: var(--teal); color: #fff; }
.type-toggle button.active.neg { background: var(--coral); color: #fff; }

/* ================================================================
   Tambahan: tema kustom, misi harian, PIN anak, panel admin
   ================================================================ */

/* ---------- Gambar latar yang diatur Admin ---------- */
.bg-art {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-size: cover; background-position: center; background-repeat: no-repeat;
}

.brand-mark.has-image { padding: 0; overflow: hidden; background: var(--surface); }
.brand-mark.has-image img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Hiasan beranda ---------- */
.hero-banner { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); margin-bottom: 18px; }
.hero-banner img { display: block; width: 100%; max-height: 240px; object-fit: cover; }

.decor-strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px; margin-top: 18px; }
.decor-strip figure { flex: none; margin: 0; width: 130px; height: 96px; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-soft); background: var(--surface); }
.decor-strip img { width: 100%; height: 100%; object-fit: cover; }

.parent-link { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

/* ---------- Kunci profil anak ---------- */
.kid-card { position: relative; }
.lock-badge { position: absolute; top: 12px; right: 14px; font-size: 15px; opacity: .75; }
.pin-dots span.optional { background: transparent; border: 2px dashed var(--bg-deep); width: 12px; height: 12px; align-self: center; }
.pin-avatar { width: 68px; height: 68px; border-radius: 50%; overflow: hidden; margin: 0 auto 12px; background: var(--primary-tint); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.pin-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pin-card .pill-btn.ghost { margin-top: 16px; }

.pin-block { border-top: 1px solid var(--bg-deep); padding-top: 14px; margin-top: 16px; }
.pin-manage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pin-manage input { flex: 1 1 150px; width: auto; }

/* ---------- Misi Hari Ini ---------- */
.today-card {
  background: linear-gradient(160deg, var(--surface), var(--primary-tint) 150%);
  border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-soft); margin-bottom: 16px;
}
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.today-date { font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.today-sub { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }
.today-ring {
  flex: none; width: 62px; height: 62px; border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--pct, 0) * 1%), var(--bg-deep) 0);
  display: grid; place-items: center;
}
.today-ring span {
  width: 46px; height: 46px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 12.5px;
}
.today-bar { height: 10px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.today-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--teal)); transition: width .5s ease; }

.daily-group { padding: 16px 18px; margin-bottom: 12px; }
.daily-group .section-title { margin-bottom: 8px; }
.daily-group .section-title h3 { font-size: 15px; }
.daily-list { display: grid; gap: 2px; }

.daily-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--bg-deep); }
.daily-item:last-child { border-bottom: none; }
.daily-item .di-check { font-size: 19px; line-height: 1; flex: none; }
.daily-item .di-main { flex: 1; min-width: 0; }
.daily-item .di-name { font-weight: 800; font-size: 14px; }
.daily-item .di-meta { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.daily-item .daily-count { font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: var(--ink-soft); flex: none; }
.daily-item .qbtn { flex: none; background: var(--primary); color: #fff; font-weight: 700; font-size: 12.5px; padding: 8px 15px; border-radius: 999px; }
.daily-item .qbtn.done, .daily-item .qbtn:disabled { background: var(--bg-deep); color: var(--ink-soft); }
.daily-item.done .di-name { text-decoration: line-through; color: var(--ink-soft); }
.daily-item.waiting .di-meta { color: #9A6B00; }

/* ---------- Pemilih hari ---------- */
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker .dayBtn {
  flex: 1 1 40px; min-width: 40px; padding: 9px 4px; border-radius: var(--radius-sm);
  background: var(--bg); font-weight: 800; font-size: 12px; color: var(--ink-soft);
}
.day-picker .dayBtn.active { background: var(--primary); color: #fff; }

.activity-row { flex-wrap: wrap; }
.ar-actions { display: flex; gap: 6px; flex: none; }
.ar-schedule { flex-basis: 100%; display: grid; gap: 10px; padding: 12px 0 4px; }

/* ---------- Panel Admin ---------- */
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.preset-row .presetBtn { font-size: 12.5px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.color-grid input[type="color"] { height: 44px; padding: 4px; }
.sticky-actions { position: sticky; bottom: 12px; background: var(--surface); padding: 12px; border-radius: var(--radius-md); box-shadow: var(--shadow-soft); justify-content: flex-end; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media-cell { display: grid; gap: 7px; }
.media-thumb { height: 110px; border-radius: var(--radius-md); overflow: hidden; background: var(--bg); }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-title { font-size: 12.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-cell select { width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 2px solid var(--bg-deep); background: var(--bg); font-family: var(--font-body); font-weight: 700; font-size: 12.5px; color: var(--ink); }
.media-cell .pill-btn { font-size: 12px; padding: 7px 12px; }

.radio-list { display: grid; gap: 10px; }
.radio-list label { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--ink); cursor: pointer; }
.radio-list input[type="radio"] { width: auto; margin-top: 3px; flex: none; }

.preview-box { background: var(--bg); border-radius: var(--radius-md); padding: 14px 16px; font-size: 13px; font-weight: 700; line-height: 1.6; margin-bottom: 14px; }
.danger-card { border: 2px solid var(--coral-tint); }
.warn-card { border: 2px solid var(--gold); }
.warn-list { margin: 0; padding-left: 20px; font-size: 13.5px; font-weight: 700; line-height: 1.7; }
.preview-box code, .muted code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-deep); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .today-head { align-items: flex-start; }
  .daily-item { flex-wrap: wrap; }
  .daily-item .di-main { flex-basis: calc(100% - 100px); }
}
