/* ==========================================================================
   STEMA Math Practice Platform - shared styles
   Palette: mint #b6e2d3 | coral #eb7a61 | blue #4378a5 | green #61af8e
   ========================================================================== */
:root {
  --mint: #b6e2d3;
  --coral: #eb7a61;
  --blue: #4378a5;
  --green: #61af8e;
  --cream: #fff7f5;
  --cream-border: #f0d1cb;
  --ink: #333;
  --muted: #777;
  --ok: #2e8b57;
  --bad: #d64545;
  --radius: 20px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito", "Trebuchet MS", Arial, sans-serif;
  background: var(--mint);
  color: var(--ink);
  min-height: 100vh;
}

a { color: var(--blue); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand img { height: 40px; }
.topbar .brand span { font-weight: 900; color: var(--coral); font-size: 1.55rem; letter-spacing: .5px; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-weight: 700; }
.topbar .user .who { color: var(--blue); }
/* child profile dropdown (top-right) */
.child-select { display: flex; align-items: center; gap: 7px; }
.child-select .cs-label { color: var(--muted); font-weight: 800; font-size: .9rem; }
.child-select select { font-family: inherit; font-weight: 800; color: var(--blue); font-size: .95rem;
  padding: 8px 30px 8px 12px; border: 2px solid var(--cream-border); border-radius: 12px; background: #fff;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234378a5' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.child-select select:focus { outline: none; border-color: var(--blue); }
/* avatar chips + profile link */
.ava { display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; line-height: 1; }
.ava.sm { width: 30px; height: 30px; border-radius: 50%; background: var(--cream); border: 2px solid var(--cream-border);
  font-size: 1rem; overflow: hidden; flex: 0 0 auto; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar .user .who { display: inline-flex; align-items: center; gap: 7px; }
.profile-chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800;
  color: var(--blue); padding: 5px 12px 5px 6px; border: 2px solid var(--cream-border); border-radius: 999px;
  background: #fff; transition: border-color .12s ease, box-shadow .12s ease; }
.profile-chip:hover { border-color: var(--blue); box-shadow: 0 4px 12px rgba(0,0,0,.08); }

/* ---------- profile / account page ---------- */
.profile-card { background: #fff; border: 2px solid #eef2f6; border-radius: 20px; padding: 24px 22px;
  box-shadow: 0 8px 22px rgba(0,0,0,.05); margin-bottom: 18px; }
.avatar-edit { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.avatar-preview { width: 84px; height: 84px; border-radius: 50%; background: var(--cream); border: 3px solid var(--cream-border);
  display: flex; align-items: center; justify-content: center; font-size: 2.6rem; overflow: hidden; flex: 0 0 auto; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-controls { display: flex; flex-direction: column; gap: 10px; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.emoji-pick { font-size: 1.4rem; line-height: 1; padding: 5px 7px; border: 2px solid var(--cream-border);
  background: #fff; border-radius: 12px; cursor: pointer; transition: transform .1s ease, border-color .1s ease; }
.emoji-pick:hover { transform: scale(1.12); border-color: var(--blue); }
.kid-card .avatar-preview { width: 66px; height: 66px; font-size: 2rem; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.add-card { border-style: dashed; border-color: var(--cream-border); background: #fbfdff; }
.add-card .avatar-preview { width: 66px; height: 66px; font-size: 2rem; }

/* consent checkbox on the register form */
.agree-box { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0 6px; font-size: .92rem;
  color: var(--muted); line-height: 1.45; font-weight: 600; }
.agree-box input { margin-top: 3px; flex: 0 0 auto; width: 18px; height: 18px; }
.agree-box a { color: var(--coral); font-weight: 800; }

/* ---------- static content pages (terms / privacy / feedback) ---------- */
.doc-wrap { max-width: 800px; margin: 0 auto; padding: 26px 22px 60px; }
.doc-nav { display: flex; align-items: center; justify-content: space-between; max-width: 1160px; margin: 0 auto; padding: 16px 24px; }
.doc-nav .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.doc-nav .brand img { height: 44px; }
.doc-nav .brand b { color: var(--coral); font-size: 1.5rem; font-weight: 900; letter-spacing: .5px; }
.doc { background: #fff; border: 2px solid #eef2f6; border-radius: 20px; padding: 30px 32px; box-shadow: 0 8px 22px rgba(0,0,0,.05); }
.doc h1 { color: var(--blue); margin: 0 0 4px; }
.doc .updated { color: var(--muted); font-weight: 700; margin: 0 0 22px; font-size: .9rem; }
.doc h2 { color: #2c4a63; font-size: 1.2rem; margin: 26px 0 8px; }
.doc p, .doc li { color: #40566a; line-height: 1.6; }
.doc ul { padding-left: 20px; }
.doc a { color: var(--blue); }
.site-footer { text-align: center; color: var(--muted); padding: 28px; font-size: .9rem; }
.site-footer a { color: var(--blue); text-decoration: none; margin: 0 6px; }

/* ---------- generic page wrapper ---------- */
.wrap { max-width: 1000px; margin: 0 auto; padding: 26px 18px 60px; }
.page-head { text-align: center; margin-bottom: 26px; }
.page-head h1 { color: var(--coral); font-size: 2rem; margin: 6px 0; }
.page-head p { color: var(--muted); margin: 0; }
.breadcrumb { text-align: center; margin-bottom: 6px; font-weight: 700; color: var(--blue); }
.breadcrumb a { text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--green);
  color: #fff;
  transition: transform 0.12s ease, opacity 0.12s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-2px); opacity: 0.95; }
.btn.blue { background: var(--blue); }
.btn.coral { background: var(--coral); }
.btn.ghost { background: #eee; color: var(--ink); }
.btn:disabled { background: #cccccc; cursor: not-allowed; transform: none; opacity: 0.7; }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }

/* ---------- card grid (grades / topics) ---------- */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.tile {
  position: relative;
  background: #fff;
  border: 3px solid var(--cream-border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  justify-content: center;
}
.tile:hover { transform: translateY(-3px); border-color: var(--coral); }
.tile .tile-num { font-size: 2.2rem; font-weight: 900; color: var(--blue); line-height: 1; }
.tile .tile-title { font-weight: 800; font-size: 1rem; }
.tile .tile-sub { font-size: 0.8rem; color: var(--muted); }
.tile.done { border-color: var(--green); background: #f2fbf7; }
.tile.locked { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.4); }
.tile.locked:hover { transform: none; border-color: var(--cream-border); }

/* check / progress badges */
.check {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.tile .score-pill {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--green);
}
.progress-bar {
  height: 8px;
  border-radius: 8px;
  background: #eee;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar > span { display: block; height: 100%; background: var(--green); }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-card img.logo { height: 46px; margin-bottom: 8px; }
.auth-card h1 { color: var(--coral); font-size: 1.6rem; margin: 6px 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 0.95rem; }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 5px; color: var(--blue); }
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid #ddd;
  border-radius: 12px;
  outline: none;
  font-family: inherit;
}
.field input:focus { border-color: var(--green); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-switch { margin-top: 16px; font-size: 0.9rem; color: var(--muted); }
.form-msg { min-height: 20px; margin: 8px 0 2px; font-weight: 700; font-size: 0.9rem; }
.form-msg.bad { color: var(--bad); }
.form-msg.ok { color: var(--ok); }

/* ---------- practice / quiz ---------- */
.quiz-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 24px 30px;
  text-align: center;
}
.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.quiz-top .qcount { font-weight: 800; color: var(--blue); }
.quiz-top .qscore { font-weight: 800; color: var(--green); }
.quiz-progress { height: 10px; border-radius: 10px; background: #eee; overflow: hidden; margin-bottom: 22px; }
.quiz-progress > span { display: block; height: 100%; background: var(--coral); transition: width 0.3s ease; }
.prompt { font-size: 1.5rem; font-weight: 800; color: var(--blue); margin: 10px auto 18px; line-height: 1.5; max-width: 600px; }
.prompt.big { font-size: 2.4rem; color: var(--blue); }
.visual { margin: 6px auto 20px; max-width: 460px; }
.visual svg { max-width: 100%; height: auto; }

.answer-number input {
  width: 220px; max-width: 100%;
  padding: 14px;
  font-size: 1.6rem;
  text-align: center;
  border: 3px solid #d9d9d9;
  border-radius: 16px;
  outline: none;
  font-family: inherit;
}
.answer-number input:focus { border-color: var(--green); }

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
}
.choice {
  border: 3px solid #e2e2e2;
  background: #fff;
  border-radius: 16px;
  padding: 16px 12px;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
  font-family: inherit;
  color: var(--ink);
}
.choice:hover { transform: translateY(-2px); border-color: var(--blue); }
.choice.selected { border-color: var(--blue); background: #eef4fb; }
.choice.correct { border-color: var(--green); background: #eafaf2; }
.choice.wrong { border-color: var(--bad); background: #fdeeee; }
.choice svg { display: block; margin: 0 auto; }
.choice:disabled { cursor: default; }

.quiz-msg { min-height: 30px; margin: 18px 0 8px; font-size: 1.15rem; font-weight: 800; }
.quiz-msg.correct { color: var(--ok); }
.quiz-msg.wrong { color: var(--bad); }
.quiz-actions { margin-top: 16px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* results */
.result .emoji { font-size: 4rem; }
.result h2 { color: var(--coral); margin: 6px 0; }
.result .big-score { font-size: 2.6rem; font-weight: 900; color: var(--blue); margin: 10px 0; }
.result .verdict { font-size: 1.2rem; font-weight: 800; margin-bottom: 18px; }
.result .verdict.pass { color: var(--ok); }
.result .verdict.fail { color: var(--coral); }

.loading { text-align: center; color: var(--muted); padding: 40px; font-weight: 700; }
.hidden { display: none !important; }

@media (max-width: 600px) {
  .prompt.big { font-size: 2rem; }
  .page-head h1 { font-size: 1.6rem; }
}

/* ==========================================================================
   Registration / account forms, child profiles, admin
   ========================================================================== */
.auth-card.wide { max-width: 780px; }
.form-section { text-align: left; color: var(--blue); margin: 18px 0 8px; font-size: 1.05rem; border-top: 1px solid #eee; padding-top: 16px; }
.form-section:first-of-type { border-top: none; padding-top: 0; }
.muted-note { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.child-row { border: 1px dashed #dfe4ea; border-radius: 14px; padding: 10px 12px 2px; margin-bottom: 10px; text-align: left; }
.child-row .remove-child { color: var(--bad); font-size: 0.85rem; font-weight: 700; text-decoration: none; }
.auth-card.wide .btn.small { width: auto; margin: 0 0 8px; }

.opt-details { text-align: left; margin: 12px 0; }
.opt-details > summary { cursor: pointer; font-weight: 800; color: var(--blue); padding: 6px 0; }
.opt-details[open] > summary { margin-bottom: 8px; }

.msg { border-radius: 14px; padding: 14px 16px; font-weight: 600; line-height: 1.5; text-align: left; }
.msg.ok { background: #eafaf2; color: var(--ok); border: 1px solid #bfe8d4; }
.msg.bad { background: #fdeeee; color: var(--bad); border: 1px solid #f3caca; }
.msg a { font-weight: 800; }

/* child profile picker */
.child-grid { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.child-card { background: #fff; border: 3px solid var(--cream-border); border-radius: 22px; padding: 26px 30px;
  cursor: pointer; font-family: inherit; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.child-card:hover { transform: translateY(-4px); border-color: var(--green); box-shadow: var(--shadow); }
.child-card .child-ava { font-size: 3rem; }
.child-card .child-name { font-weight: 800; color: var(--blue); font-size: 1.1rem; margin-top: 6px; }
.child-card:disabled { opacity: .6; cursor: default; }

/* admin panel */
.btn.danger { background: var(--bad); color: #fff; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); margin: 8px 0; }
.admin .admin-create { background: #fff; border: 2px solid #eef2f6; border-radius: 16px; padding: 6px 18px; margin-bottom: 18px; }
.admin .admin-create > summary { cursor: pointer; font-weight: 800; color: var(--coral); padding: 10px 0; }
.admin .admin-create form { padding-bottom: 12px; }
.acct { background: #fff; border: 2px solid #eef2f6; border-radius: 16px; padding: 16px 18px; margin-bottom: 12px;
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.acct.off { opacity: .6; }
.acct-name { font-weight: 800; color: #2c4a63; font-size: 1.05rem; }
.acct-meta { color: var(--muted); font-size: 0.9rem; margin: 3px 0; }
.acct-kids { color: var(--blue); font-size: 0.9rem; font-weight: 700; }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 0.68rem; font-weight: 900; padding: 2px 8px; border-radius: 20px; margin-left: 6px; vertical-align: middle; }
.badge.admin { background: #4378a5; color: #fff; }
.badge.ok { background: #eafaf2; color: var(--ok); }
.badge.warn { background: #fff6e6; color: #8a6d1a; }
.badge.bad { background: #fdeeee; color: var(--bad); }
