* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, sans-serif;
  margin: 0; background: #f2f4f8; color: #1c2333;
}
header.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #26324a; color: #fff; padding: 10px 18px;
}
header.topbar .brand { font-size: 22px; font-weight: 700; }
header.topbar nav { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
header.topbar a, header.topbar button.linkbtn {
  color: #fff; text-decoration: none; background: #3a4a68; border: 0;
  padding: 8px 14px; border-radius: 999px; font-size: 15px; cursor: pointer;
}
header.topbar .who { opacity: .85; font-size: 14px; }
.flash {
  background: #fff3cd; border: 1px solid #e6cf7a; color: #5c4a00;
  margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px;
}
main { padding: 16px 18px 40px; }

/* board: two kid columns */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .board { grid-template-columns: 1fr; } }
/* board page: each kid's column scrolls on its own */
body.boardpage { display: flex; flex-direction: column; height: 100dvh; }
body.boardpage main { flex: 1; min-height: 0; display: flex; }
body.boardpage .board { flex: 1; min-height: 0; width: 100%; }
body.boardpage .kidcol { overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) {
  body.boardpage .board { grid-template-rows: 1fr 1fr; }
}
.kidcol {
  background: #fff; border-radius: 16px; padding: 14px 14px 18px;
  box-shadow: 0 1px 4px rgba(20,30,60,.08);
}
.kidcol h2 { margin: 2px 4px 12px; font-size: 28px; }
.kidcol.c1 h2 { color: #6d3fc4; }
.kidcol.c3 h2 { color: #d96c00; }
.kidcol.c4 h2 { color: #1f6fd6; }
.kidcol.c5 h2 { color: #c2187a; }
.kidcol.c6 h2 { color: #4a8f1f; }
.kidcol.c2 h2 { color: #0e7a6d; }
.kidcol h3 { margin: 18px 4px 8px; font-size: 17px; color: #5a6578; }
.empty { color: #7a8499; font-size: 17px; padding: 8px 4px; }

/* reward points */
.pointsbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff8e1; border: 1px solid #f0df9a; border-radius: 12px;
  padding: 8px 14px; margin: 0 0 14px;
}
.points-total {
  font-size: 30px; font-weight: 800; color: #8a6400;
  display: inline-block; transform-origin: 50% 80%;
  animation: wave 2.4s ease-in-out infinite;
}
.points-total.pulse { animation: bigpulse .8s ease-in-out; }
.points-detail { font-size: 15px; color: #6a5a17; }
@keyframes wave {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(4deg) scale(1.1); }
}
@keyframes bigpulse {
  40% { transform: scale(1.55) rotate(7deg); }
  100% { transform: scale(1); }
}
.flystar {
  position: fixed; z-index: 999; font-size: 22px; pointer-events: none;
  transform: translate(-50%, -50%);
  animation: fly .95s ease-out forwards;
}
@keyframes fly {
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
       scale(1.5) rotate(50deg); opacity: 0; }
}

.card {
  position: relative;
  border: 2px solid #dfe4ee; border-inline-start: 10px solid #b9c2d4;
  border-radius: 12px; padding: 12px 14px; margin: 0 0 10px;
  display: flex; gap: 12px; align-items: flex-start; background: #fff;
}
.taskcount { display: inline-block; background: #eef1f7; color: #44506a; font-size: .5em; font-weight: 800; padding: .25em .7em; border-radius: 999px; vertical-align: .55em; letter-spacing: .03em; }
.card.collapsing { transition: height .38s ease, opacity .38s ease, margin .38s ease, padding .38s ease; overflow: hidden; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-size: 20px; font-weight: 650; line-height: 1.25; }
.newbadge { display: inline-block; background: #ffd94d; color: #5a4300; font-size: .62em; font-weight: 800; letter-spacing: .05em; padding: .12em .5em; border-radius: 999px; vertical-align: .3em; }
.recbadge { display: inline-block; background: #dceeff; color: #2050a0; font-size: .62em; font-weight: 800; letter-spacing: .05em; padding: .12em .5em; border-radius: 999px; vertical-align: .3em; }
.infobadge { display: inline-block; background: #e8ecf4; color: #44506a; font-size: .62em; font-weight: 800; letter-spacing: .05em; padding: .12em .5em; border-radius: 999px; vertical-align: .3em; }
.schoolbadge { display: inline-block; font-size: .85em; font-weight: 800; letter-spacing: .04em; padding: .1em .5em; border-radius: 999px; }
.schoolbadge { background: #e8edf5; color: #40506b; }
.viewpost { margin-top: 8px; background: #eef4ff; color: #2050a0; border: 2px solid #b9d2f5; border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 700; cursor: pointer; min-height: 44px; }
.worth { font-weight: 800; font-size: 1.12em; color: #9a6a00; }
.viewpost:active { background: #d9e8ff; }
.imgmodal { position: fixed; inset: 0; background: rgba(10, 14, 24, .88); z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.imgmodal[hidden] { display: none; }
.imgmodal img { max-width: 94vw; max-height: 82vh; border-radius: 10px; background: #fff; }
.imgmodal-close { background: #ffd94d; color: #4a3800; border: none; border-radius: 999px; padding: 12px 26px; font-size: 17px; font-weight: 800; cursor: pointer; min-height: 48px; }
.card .details { font-size: 16.5px; color: #2f3a52; margin-top: 4px; white-space: pre-wrap; line-height: 1.4; }
.card .due { font-size: 14px; font-weight: 600; margin-top: 6px; }
.card .src { font-size: 12px; color: #8a93a8; margin-top: 2px; text-transform: capitalize; }
.card.overdue { border-color: #e05252; border-inline-start-color: #d61f1f; background: #fff1f1; }
.card.overdue .due { color: #b30d0d; }
.card.today { border-color: #f08c2e; border-inline-start-color: #ef7d00; background: #fff6ea; }
.card.today .due { color: #b25f00; }
.card.soon { border-color: #e7c93f; border-inline-start-color: #dcb400; background: #fffbe8; }
.card.soon .due { color: #7a6400; }
.card.near { border-inline-start-color: #7fb069; background: #fbfef7; }
.card.near .due, .card.later .due, .card.none .due { color: #44506a; }
.card.done { opacity: .62; }
.card.done .title { text-decoration: line-through; }
button.donebtn, button.undobtn {
  border: 0; border-radius: 999px; cursor: pointer; font-weight: 700;
  padding: 12px 18px; font-size: 16px; white-space: nowrap;
}
button.donebtn { background: #1f9d55; color: #fff; }
button.undobtn { background: #e8ecf4; color: #26324a; }
.timebar { margin-top: 8px; }
.tbtrack { position: relative; height: 9px; border-radius: 99px; background: #edf0f6; border: 1px solid #d5dbe8; }
.tbfill { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; border-radius: 99px; background: #7fb069; }
.tbfill.today { background: #ef7d00; }
.tbfill.overdue { background: #d61f1f; }
.tbfill.soon { background: #dcb400; }
.tbtick { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: #44506a; opacity: .55; border-radius: 2px; }
.rbtns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.rbtns button { border: 0; border-radius: 999px; cursor: pointer; font-weight: 800; padding: 12px 18px; font-size: 16px; min-height: 48px; color: #fff; }
.rbtns .rgreen { background: #1f9d55; }
.rbtns .rorange { background: #ef7d00; }
.rbtns .rred { background: #d61f1f; }
.colorpop { position: absolute; inset-inline-end: 12px; bottom: 12px; z-index: 5; max-width: 94%; background: #fff; border: 2px solid #b9d2f5; border-radius: 12px; padding: 10px 12px; box-shadow: 0 6px 22px rgba(20, 30, 60, .22); }
.colorpop .rq { font-size: 16px; font-weight: 700; color: #26324a; }
.retrotxt { color: #1e6b2e; font-weight: 700; }

/* forms & tables (parent pages) */
form.panel, .panel {
  background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(20,30,60,.08);
}
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
select, textarea {
  width: 100%; padding: 10px; font-size: 16px; border: 1px solid #c6cede;
  border-radius: 8px; background: #fff;
}
textarea { min-height: 64px; }
button.primary {
  background: #26324a; color: #fff; border: 0; border-radius: 10px;
  padding: 12px 20px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 14px;
}
button.small, a.small {
  background: #e8ecf4; color: #26324a; border: 0; border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; text-decoration: none;
}
button.danger { background: #f6dcdc; color: #8f1414; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 7px 8px; border-bottom: 1px solid #e6eaf2; vertical-align: top; }
.inline { display: inline; }
.checkrow { display: flex; gap: 10px; flex-wrap: wrap; }
.checkrow label { font-weight: 500; display: flex; gap: 5px; align-items: center; margin: 4px 0; }
.loginwrap { max-width: 380px; margin: 8vh auto; }
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photogrid img { width: 100%; border-radius: 10px; border: 1px solid #dfe4ee; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e8ecf4; }
.badge.pending { background: #ffe1a8; }

/* marketplace: star bank, goal card, shelf */
.goalcard {
  display: flex; gap: 12px; align-items: center;
  border: 2px solid #dfe4ee; border-radius: 12px;
  padding: 10px 14px; margin: 0 0 12px; background: #fffdf4;
  text-decoration: none; color: inherit;
}
.kidcol.c1 .goalcard { border-color: #c9aef0; }
.kidcol.c3 .goalcard { border-color: #f3c491; }
.kidcol.c4 .goalcard { border-color: #a9c8ef; }
.kidcol.c5 .goalcard { border-color: #efa9cd; }
.kidcol.c6 .goalcard { border-color: #bcd69a; }
.kidcol.c2 .goalcard { border-color: #9fd8cf; }
.goalcard.reached { border-color: #f0c93f; background: #fff8d6; }
.goalcard.pending, .goalcard.inflight { border-color: #f0c93f; background: #fff8d6; }
.goalcard .gimg { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.goalcard .gmain { flex: 1; min-width: 0; }
.goalcard .gtext { flex: 1; min-width: 0; }
.gtag { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #8a6400; }
.goalbanner { border: 2px dashed #f0c93f; background: #fff8d6; border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; font-size: 14px; }
.goalcard.pastgoal { border-style: dashed; }
.goalflag.past { opacity: .7; }
.mindform { margin-top: 8px; }
.mindbtn { background: #fff; border: 2px solid #d8b93a; color: #7a5b00; border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; cursor: pointer; }
.goalcard .gimglink { flex: 0 0 auto; line-height: 0; }
.gchange { color: #6d3fc4; text-decoration: underline; text-transform: none; letter-spacing: 0; font-size: 12px; }
.gtitle { font-size: 19px; font-weight: 700; line-height: 1.25; }
.gsub { font-size: 14px; color: #5a6578; margin-top: 2px; }
.gbar { height: 12px; border-radius: 99px; background: #edf0f6; border: 1px solid #d5dbe8; overflow: hidden; margin: 7px 0 5px; }
.gfill { height: 100%; background: #f2b705; border-radius: 99px; }
button.goalbtn {
  background: #f2b705; color: #4a3800; border: 0; border-radius: 999px;
  cursor: pointer; font-weight: 800; padding: 12px 16px; font-size: 15px;
  white-space: nowrap; min-height: 48px;
}
.pagetitle { margin: 4px 0 2px; font-size: 28px; }
.pagesub { color: #5a6578; font-size: 15px; margin: 0 0 14px; max-width: 720px; }
.bankrow { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.bankpill {
  background: #fff8e1; border: 1px solid #f0df9a; border-radius: 999px;
  padding: 8px 14px; font-size: 14px;
}
.marketgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.prod {
  background: #fff; border: 2px solid #dfe4ee; border-radius: 14px;
  padding: 10px; cursor: pointer; position: relative;
  box-shadow: 0 1px 4px rgba(20,30,60,.08);
}
.prod.sel { border-color: #f2b705; background: #fffdf0; }
.prodimg { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; }
.prodnoimg {
  height: 110px; border-radius: 10px; background: #fff8e1;
  display: flex; align-items: center; justify-content: center; font-size: 44px;
}
.prodname { font-weight: 700; font-size: 16px; margin-top: 8px; line-height: 1.25; }
.prodnote { font-size: 13px; color: #5a6578; margin-top: 2px; }
.prodprice { font-weight: 800; font-size: 17px; color: #8a6400; margin-top: 6px; }
.prodtier { font-size: 12px; color: #8a93a8; }
.goalflags {
  position: absolute; top: 8px; inset-inline-start: 8px; display: flex;
  flex-direction: column; gap: 4px; align-items: flex-start;
}
.goalflag {
  font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px; color: #fff;
}
.goalflag.c1 { background: #6d3fc4; }
.goalflag.c3 { background: #d96c00; }
.goalflag.c4 { background: #1f6fd6; }
.goalflag.c5 { background: #c2187a; }
.goalflag.c6 { background: #4a8f1f; }
.goalflag.c2 { background: #0e7a6d; }
.picker .picktitle { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.kidbtns { display: flex; gap: 10px; flex-wrap: wrap; }
.kidbtns form { flex: 1; min-width: 150px; }
button.kidbtn {
  width: 100%; border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 800; padding: 14px; font-size: 17px; min-height: 52px; color: #fff;
}
button.kidbtn.c1 { background: #6d3fc4; }
button.kidbtn.c3 { background: #d96c00; }
button.kidbtn.c4 { background: #1f6fd6; }
button.kidbtn.c5 { background: #c2187a; }
button.kidbtn.c6 { background: #4a8f1f; }
button.kidbtn.c2 { background: #0e7a6d; }
button.kidbtn[disabled] { background: #c6cede; cursor: default; }
.pickhint { font-size: 13px; color: #8a93a8; margin-top: 10px; }
img.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }

/* ---- language toggle + RTL (Arabic) ---- */
.langtoggle { display: inline-block; margin: 0 0 10px; }
header.topbar .langtoggle { margin: 0; }
.langtoggle button {
  background: #eef1f7; color: #26324a; border: 1px solid #c9d2e4;
  padding: 6px 14px; border-radius: 999px; font-size: 14px;
  font-weight: 700; cursor: pointer;
}
header.topbar .langtoggle button { background: #3a4a68; color: #fff; border: 0; padding: 8px 14px; font-size: 15px; font-weight: 400; }
.loginwrap .langtoggle { display: block; text-align: end; }

/* user-entered content is rendered exactly as typed; plaintext
   bidi handling keeps mixed Arabic/Latin + number strings in
   their natural order instead of scrambling them */
.card .title, .card .details, .gtitle, .prodname, .prodnote,
.kidcol h2, .reqtitle { unicode-bidi: plaintext; }

/* Arabic script must not be letter-spaced or uppercased */
[dir="rtl"] .gtag, [dir="rtl"] .newbadge, [dir="rtl"] .recbadge,
[dir="rtl"] .infobadge, [dir="rtl"] .schoolbadge, [dir="rtl"] .taskcount {
  letter-spacing: 0;
}
[dir="rtl"] .gtag { text-transform: none; }
/* emails and passwords are Latin-script: keep those fields LTR */
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="password"] {
  direction: ltr; text-align: left;
}
