/* VOICE: warm and encouraging, for children memorising the Quran and the parent listening to them
   IDEA: an illuminated mushaf at night: deep teal pages, gold ornament, a khatam star that fills as ayat are memorised
   PICTURE: the 8-point khatam star as badge, ayah marker and juz tile; an hourglass-like time bank
   COLOUR and TYPE: teal-ink night field, warm parchment cards, gold accent; each child has a hue; Amiri Quran for ayat, Baloo 2 + Nunito for UI */
:root {
  --night: #0f2a2e; --night2: #163a3f; --night3: #1f4a50;
  --paper: #fbf6ea; --paper2: #f3ead4; --ink: #1d2a2c; --muted: #6a7472;
  --gold: #e9b949; --gold2: #c9952a; --goldsoft: #fbecc0;
  --ok: #2f9e6e; --oksoft: #d8f1e5; --warn: #d9822b; --bad: #c0443b;
  --kid: #2f9e6e; --kidsoft: #d8f1e5;
  --r: 18px; --shadow: 0 6px 20px rgba(8, 25, 28, .18);
}
.kid-1 { --kid: #2f9e6e; --kidsoft: #d8f1e5; }
.kid-2 { --kid: #3f6fd8; --kidsoft: #dfe7fb; }
.kid-3 { --kid: #b4508a; --kidsoft: #f6dfec; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Nunito, system-ui, sans-serif; color: var(--paper); min-height: 100vh;
  background: var(--night) radial-gradient(1200px 600px at 50% -200px, #24575d 0%, transparent 70%);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; border: 0; }
button:disabled { opacity: .45; cursor: default; }
h1, h2, h3 { font-family: 'Baloo 2', Nunito, sans-serif; margin: 0; line-height: 1.15; }
.boot { padding: 40vh 0; text-align: center; opacity: .7; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px 120px; }

/* khatam star */
.star { position: relative; display: inline-grid; place-items: center; width: var(--s, 44px); height: var(--s, 44px); flex: none; }
.star::before, .star::after { content: ''; position: absolute; inset: 14%; background: var(--c, var(--gold)); border-radius: 3px; }
.star::after { transform: rotate(45deg); }
.star > span { position: relative; z-index: 1; font-weight: 800; font-size: calc(var(--s, 44px) * .34); color: var(--night); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.login h1 { font-size: 40px; color: var(--gold); margin-top: 10px; }
.login p { opacity: .8; margin: 4px 0 18px; }
.dots { display: flex; gap: 12px; justify-content: center; margin: 14px 0 6px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); }
.dots i.on { background: var(--gold); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin-top: 14px; }
.pad button { height: 76px; border-radius: 50%; background: var(--night3); color: var(--paper); font-size: 28px; font-weight: 700; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.pad button:active { transform: scale(.95); background: var(--gold); color: var(--night); }
.pad .ghost { background: transparent; box-shadow: none; font-size: 16px; }
.err { color: #ffb4a8; min-height: 22px; font-weight: 700; }

/* top bar */
.top { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; }
.top .who { flex: 1; min-width: 0; }
.top h1 { font-size: 26px; }
.top .lvl { font-size: 14px; opacity: .85; }
.xpbar { height: 8px; background: var(--night3); border-radius: 8px; overflow: hidden; margin-top: 6px; max-width: 260px; }
.xpbar b { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--night3); color: var(--paper); font-weight: 800; font-size: 14px; }
.btn { padding: 12px 18px; border-radius: 14px; font-weight: 800; background: var(--gold); color: var(--night); box-shadow: 0 3px 0 var(--gold2); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gold2); }
.btn.kid { background: var(--kid); color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.btn.soft { background: var(--paper2); color: var(--ink); box-shadow: 0 3px 0 #d9cfb6; }
.btn.line { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.btn.danger { background: var(--bad); color: #fff; box-shadow: 0 3px 0 #8d2c25; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.link { background: none; color: inherit; text-decoration: underline; padding: 4px; opacity: .8; }

/* cards */
.card { background: var(--paper); color: var(--ink); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 21px; margin-bottom: 10px; }
.card .sub { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* time bank */
.bank { background: linear-gradient(150deg, var(--night2), var(--night3)); color: var(--paper); position: relative; overflow: hidden; }
.bank .big { font-family: 'Baloo 2'; font-size: 52px; font-weight: 800; color: var(--gold); line-height: 1; }
.bank .rule { font-size: 14px; opacity: .85; margin-top: 6px; }
.bank .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
@media (max-width: 420px) { .bank .stats { grid-template-columns: repeat(2, 1fr); } }
.bank .stats div { font-size: 13px; opacity: .9; }
.bank .stats b { display: block; font-size: 22px; font-family: 'Baloo 2'; color: var(--paper); }
.bank::after { content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; opacity: .08;
  background: conic-gradient(from 22.5deg, var(--gold) 0 12.5%, transparent 0 25%, var(--gold) 0 37.5%, transparent 0 50%, var(--gold) 0 62.5%, transparent 0 75%, var(--gold) 0 87.5%, transparent 0); border-radius: 50%; }

.tasmik { background: var(--goldsoft); border: 2px dashed var(--gold2); }
.next { display: flex; gap: 14px; align-items: center; }
.next .ar { font-family: 'Amiri Quran', serif; font-size: 26px; direction: rtl; }

/* juz tabs and surah tiles */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.tabs button { flex: none; padding: 8px 12px; border-radius: 12px; background: var(--paper2); color: var(--ink); font-weight: 800; font-size: 14px; position: relative; }
.tabs button.on { background: var(--kid); color: #fff; }
.tabs button .fill { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 3px; background: rgba(0,0,0,.12); overflow: hidden; }
.tabs button .fill i { display: block; height: 100%; background: var(--gold2); }
.surahs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: #fff; border-radius: 14px; padding: 12px; text-align: left; color: var(--ink); box-shadow: 0 2px 0 #e7dfca; display: flex; gap: 10px; align-items: center; }
.tile .nm { font-weight: 800; font-size: 15px; line-height: 1.15; }
.tile .ar { font-family: 'Amiri Quran', serif; font-size: 18px; color: var(--muted); }
.tile .cnt { font-size: 12px; color: var(--muted); }
.tile.done { background: var(--goldsoft); box-shadow: 0 2px 0 var(--gold2); }
.ring { --p: 0; width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: conic-gradient(var(--kid) calc(var(--p) * 1%), #ece5d3 0); }
.ring::before { content: attr(data-n); width: 32px; height: 32px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.tile.done .ring { background: var(--gold); }
.tile.done .ring::before { content: '✓'; background: var(--goldsoft); color: var(--gold2); font-size: 16px; }
.tile .pend { font-size: 11px; font-weight: 800; color: var(--warn); }

/* badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 14px; background: var(--paper2); }
.badge .ic { font-size: 30px; filter: grayscale(1); opacity: .35; }
.badge.got { background: var(--goldsoft); }
.badge.got .ic { filter: none; opacity: 1; }
.badge .bn { font-weight: 800; font-size: 13px; margin-top: 4px; }
.badge .bd { font-size: 11px; color: var(--muted); }

/* juz map */
.juzmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.juzmap div { aspect-ratio: 1; border-radius: 8px; background: #ece5d3; position: relative; overflow: hidden; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.juzmap div i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--kid); opacity: .35; }
.juzmap div.full { background: var(--gold); color: var(--night); }
.juzmap div span { position: relative; }

/* surah reader */
.reader-head { position: sticky; top: 0; z-index: 5; background: var(--night); padding: 10px 0; display: flex; align-items: center; gap: 10px; }
.reader-head .ttl { flex: 1; min-width: 0; }
.reader-head .ar { font-family: 'Amiri Quran', serif; font-size: 24px; color: var(--gold); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tools .chip.on { background: var(--gold); color: var(--night); }
.ayah { background: var(--paper); color: var(--ink); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: right; border: 3px solid transparent; }
.ayah .txt { flex: 1; direction: rtl; }
.ayah .arb { font-family: 'Amiri Quran', serif; font-size: 27px; line-height: 2.1; }
.ayah .tl { direction: ltr; text-align: left; font-size: 13px; color: var(--muted); margin-top: 4px; font-style: italic; }
.ayah .st { font-size: 12px; font-weight: 800; direction: ltr; text-align: left; margin-top: 6px; }
.ayah.sel { border-color: var(--warn); background: #fff6e8; }
.ayah.sel .st { color: var(--warn); }
.ayah.mem { background: var(--oksoft); }
.ayah.mem .st { color: var(--ok); }
.ayah.prior { background: #e9efe9; }
.hide .ayah .arb, .hide .ayah .tl { filter: blur(7px); transition: filter .2s; }
.hide .ayah.peek .arb, .hide .ayah.peek .tl { filter: none; }
.bismillah { text-align: center; font-family: 'Amiri Quran', serif; font-size: 28px; color: var(--gold); margin: 6px 0 14px; }

.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(15, 42, 46, .96); box-shadow: 0 -6px 20px rgba(0,0,0,.25); }
.dock .wrap { padding: 0; display: flex; gap: 10px; align-items: center; }

/* parent */
.kidhead { display: flex; align-items: center; gap: 12px; }
.kidhead .av { width: 46px; height: 46px; border-radius: 50%; background: var(--kid); color: #fff; display: grid; place-items: center; font-family: 'Baloo 2'; font-size: 22px; font-weight: 800; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.kpis div { background: var(--paper2); border-radius: 12px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.kpis b { display: block; font-family: 'Baloo 2'; font-size: 22px; color: var(--ink); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field select { font: inherit; font-size: 16px; padding: 10px; border-radius: 10px; border: 2px solid #e1d8c0; background: #fff; color: var(--ink); min-width: 0; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.hist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #ece5d3; }
.hist li .m { font-weight: 800; margin-left: auto; white-space: nowrap; }
.hist li .m.pos { color: var(--ok); } .hist li .m.neg { color: var(--bad); }
.hist li .d { color: var(--muted); white-space: nowrap; font-size: 12px; padding-top: 2px; }
details > summary { cursor: pointer; font-weight: 800; padding: 6px 0; }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 18, 20, .7); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.sheet { background: var(--paper); color: var(--ink); border-radius: 22px; padding: 22px; width: min(420px, 100%); text-align: center; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.sheet h2 { font-size: 24px; }
.sheet .pad button { background: var(--paper2); color: var(--ink); }
.sheet .dots i { border-color: var(--gold2); }
.sheet .dots i.on { background: var(--gold2); }
.sheet .err { color: var(--bad); }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60; background: var(--gold); color: var(--night); padding: 12px 18px; border-radius: 14px; font-weight: 800; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }
.confetti { position: fixed; top: -30px; z-index: 70; font-size: 26px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .7; } }
.empty { text-align: center; color: var(--muted); padding: 10px; }
.fam { display: flex; align-items: center; gap: 12px; }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } }
