/* Noorli: shared styles. Arabic right-to-left by default; digits always 0-9 and left-to-right. */
:root {
  --ink: #1f2933;
  --muted: #5b6573;
  --line: #e3e7ee;
  --bg: #f7f5ef;
  --card: #ffffff;
  --brand: #0e7c86;        /* teal */
  --brand-ink: #ffffff;
  --brand-soft: #e3f4f5;
  --glow: #f5b301;         /* Noor's light */
  --glow-soft: #fff4d1;
  --ok: #1f9d55;
  --ok-soft: #e4f6ec;
  --warn: #c2410c;
  --warn-soft: #fdeee4;
  --info-soft: #eef2ff;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
  --font: "Tajawal", "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums tabular-nums;
}
a { color: var(--brand); }
button, input, select { font: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; color: var(--brand); text-decoration: none; }
.brand img { width: 36px; height: 36px; }
.brand .sub { font-weight: 500; font-size: 0.85rem; color: var(--muted); }
.topbar .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 48px; }
.narrow { max-width: 520px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 10px; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- controls ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer; font-weight: 700;
  background: var(--brand); color: var(--brand-ink); min-height: 48px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--warn); }
.btn.big { font-size: 1.15rem; padding: 14px 26px; border-radius: 16px; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=tel], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; min-height: 44px;
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid #9ed8dc; outline-offset: 1px; }
.pin-input { letter-spacing: 0.4em; text-align: center; font-size: 1.4rem; direction: ltr; }
.error { color: var(--warn); font-weight: 600; margin-top: 8px; min-height: 1.2em; }
.devnote { background: var(--glow-soft); border: 1px dashed var(--glow); padding: 8px 12px; border-radius: 10px; margin-top: 10px; }
.consent { white-space: pre-wrap; background: #fbfbfd; border: 1px solid var(--line); border-radius: 12px; padding: 14px; max-height: 340px; overflow: auto; }

/* ---------- badges, stats ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; }
.badge.not_started { background: #eef0f3; color: var(--muted); }
.badge.learning { background: var(--info-soft); color: #3740a8; }
.badge.provisional { background: var(--glow-soft); color: #8a5a00; }
.badge.mastered { background: var(--ok-soft); color: var(--ok); }
.badge.needs_review { background: var(--warn-soft); color: var(--warn); }
.badge.gap { background: var(--warn-soft); color: var(--warn); }
.stat { text-align: center; }
.stat .v { font-size: 1.9rem; font-weight: 800; color: var(--brand); }
.stat .l { color: var(--muted); font-size: 0.9rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 16px; }
.tab { padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); cursor: pointer; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.evidence-link { font-size: 0.85rem; margin-inline-start: 6px; cursor: pointer; text-decoration: underline; color: var(--brand); background: none; border: 0; padding: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.alert { border-inline-start: 4px solid var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.praise { border-inline-start: 4px solid var(--ok); background: var(--ok-soft); padding: 10px 12px; border-radius: 10px; }
.child-card { display: flex; flex-direction: column; gap: 10px; }
.child-card .name { font-size: 1.3rem; font-weight: 800; }
.champion-avatar { width: 54px; height: 54px; border-radius: 18px; background: #fff0c7; color: #826212; font-size: 1.9rem; display: grid; place-items: center; }
.champion-label { color: var(--brand); font-size: .9rem; font-weight: 700; }
.champion-preview { border-block-start: 1px solid var(--line); margin-top: 4px; }
.steps-table { width: 100%; border-collapse: collapse; }
.steps-table td, .steps-table th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: start; }
.ok-mark { color: var(--ok); font-weight: 800; }
.bad-mark { color: var(--warn); font-weight: 800; }
.report-text { white-space: pre-wrap; font-size: 1.05rem; }
.scroll-x { overflow-x: auto; }

/* ---------- long-division board ---------- */
.board-wrap { display: flex; justify-content: center; margin: 8px 0 4px; }
.board {
  direction: ltr; display: grid; gap: 2px 0; font-size: 2rem; font-weight: 700;
  font-family: "Tajawal", "Segoe UI", Arial, sans-serif; color: var(--ink);
}
.board .cell { width: 1.25em; height: 1.45em; display: flex; align-items: center; justify-content: center; }
.board .q { color: var(--brand); }
.board .q.bad, .board .w.bad { color: var(--warn); }
.board .dividend { border-top: 3px solid var(--ink); }
.board .bracket { border-left: 3px solid var(--ink); border-top: 3px solid var(--ink); border-top-left-radius: 14px; }
.board .under { border-bottom: 2px solid var(--muted); }
.board .minus { color: var(--muted); font-weight: 600; }
.board .next { background: var(--glow-soft); border-radius: 8px; box-shadow: inset 0 0 0 2px var(--glow); }
.board.small { font-size: 1.3rem; }

/* ---------- child app ---------- */
body.kid { background: linear-gradient(180deg, #fff8e6 0%, #f3fbfb 60%); }
.kid .wrap { max-width: 760px; }
.noor-row { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 14px; }
.noor-row img { width: 72px; height: 72px; flex: none; filter: drop-shadow(0 4px 10px rgba(245, 179, 1, 0.35)); }
.bubble {
  background: #fff; border: 2px solid var(--glow); border-radius: 18px; padding: 12px 16px; font-size: 1.15rem;
  box-shadow: var(--shadow); flex: 1; min-height: 52px;
}
.bubble p { margin: 0 0 4px; }
.bubble p.old { color: var(--muted); font-size: 0.95rem; }
.mission { text-align: center; padding: 26px 18px; }
.mission h1 { font-size: 1.8rem; }
.problem-card { text-align: center; }
.prompt { font-size: 1.35rem; font-weight: 700; margin: 10px 0; }
.simple-q { font-size: 2.4rem; font-weight: 800; direction: ltr; margin: 12px 0; }
.answer-box {
  direction: ltr; font-size: 2.2rem; font-weight: 800; min-width: 3.2em; min-height: 1.6em; display: inline-block;
  border-bottom: 4px solid var(--brand); padding: 0 12px; margin: 6px 0 12px;
}
.pad { direction: ltr; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 330px; margin: 0 auto; }
.pad button {
  font-size: 1.7rem; font-weight: 800; padding: 14px 0; border-radius: 16px; border: 0; cursor: pointer;
  background: #fff; box-shadow: 0 2px 0 #d9dee6; min-height: 60px;
}
.pad button:active { transform: translateY(2px); box-shadow: none; }
.pad .go { background: var(--brand); color: #fff; box-shadow: 0 2px 0 #075961; }
.pad .del { background: #f1f3f6; }
.helpers { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.progress-dots { display: flex; gap: 6px; }
.progress-dots span { width: 12px; height: 12px; border-radius: 50%; background: #e1e5ea; }
.progress-dots span.done { background: var(--glow); }
.stars { font-weight: 800; color: #8a5a00; }
.celebrate { animation: pop 0.6s ease; }
@keyframes pop { 0% { transform: scale(0.9); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .celebrate { animation: none; } }

/* ---------- Noor conversations ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.subject-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px; border-radius: 18px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; font-size: 1.1rem; color: var(--ink);
}
.subject-card:hover, .subject-card:focus-visible { border-color: var(--brand); }
.subject-icon { font-size: 2rem; }
.topic-list { display: flex; flex-direction: column; gap: 8px; }
.topic-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: start;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 1.02rem;
}
.topic-btn:hover { border-color: var(--brand); }
.chat-wrap { display: flex; flex-direction: column; gap: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 58vh; overflow-y: auto; padding: 4px 2px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; }
.msg p { margin: 0; padding: 10px 14px; border-radius: 18px; font-size: 1.12rem; white-space: pre-wrap; }
.msg.noor { align-self: flex-start; }
.msg.noor img { width: 38px; height: 38px; flex: none; }
.msg.noor p { background: #fff; border: 2px solid var(--glow); }
.msg.noor.disclosure p { border-style: dashed; color: var(--muted); font-size: 0.95rem; }
.msg.noor.thinking p { color: var(--muted); font-style: italic; }
.msg.child { align-self: flex-end; }
.msg.child p { background: var(--brand); color: #fff; }
.msg.child.note p { background: var(--brand-soft); color: var(--brand); font-size: 0.95rem; }
.composer { text-align: center; }
.composer textarea { flex: 1; min-height: 52px; resize: vertical; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.choice { min-width: 120px; font-size: 1.1rem; }

/* ---------- footer and public pages ---------- */
.site-footer { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 18px 16px 30px; font-size: 0.9rem; }
.site-footer a { color: var(--muted); }
.legal { max-width: 760px; }
.legal h2 { margin-top: 22px; }
.legal li { margin-bottom: 6px; }
.ai-note { font-size: 0.9rem; color: var(--muted); margin-top: 6px; }

/* ---------- print (reports) ---------- */
/* Short missions and the parent overview share a restrained, readable layout. */
.eyebrow { color: var(--brand); font-size: .9rem; font-weight: 700; margin: 0 0 8px; }
.mission-hero { background: linear-gradient(145deg, #fff 50%, #e3f4f5); padding: 24px; }
.mission-intro { max-width: 42ch; margin: 12px auto; }
.mission-path { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 16px 0; }
.mission-stone { display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; width: 44px; height: 44px; background: white; font-weight: 800; }
.mission-stone.done { background: var(--brand); border-color: var(--brand); color: white; }
.mission-stone.current { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.mission-count { flex-basis: 100%; text-align: center; color: var(--muted); font-size: .9rem; }
.mission-why { margin-top: 18px; text-align: start; color: var(--muted); }
.mission-why summary, .skill-map summary { cursor: pointer; padding: 12px 0; min-height: 48px; font-weight: 700; }
.skill-map summary { color: var(--brand); }
.mission-why p { margin: 6px 0; }
.setup-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.setup-step { border-block-start: 3px solid var(--line); padding: 12px 6px; color: var(--muted); }
.setup-step.is-current { border-color: var(--brand); color: var(--ink); font-weight: 700; }
.setup-step.is-complete { border-color: var(--ok); }
.experience-intro { max-width: 65ch; color: var(--muted); }
.dashboard-section { scroll-margin-top: 110px; margin-top: 22px; }
.section-navigation summary, .overview-scope summary { cursor: pointer; min-height: 48px; padding: 12px 0; }
.section-navigation summary { color: var(--brand); font-weight: 700; }
.section-navigation nav { padding: 4px 0 12px; }
.overview-scope { margin-top: 8px; }
.child-switch { max-width: 300px; min-width: 0; }
.tab, .evidence-link { min-height: 48px; display: inline-flex; align-items: center; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.kid .topbar { flex-wrap: wrap; }
.kid .topbar .brand { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .kid .topbar .actions { margin-inline-start: auto; }
  .dashboard-section .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-section .stat { padding: 16px 10px; margin-bottom: 0; }
  .mission-hero { padding: 20px 16px; }
  .tabs { flex-wrap: nowrap; }
  .tab { flex: 1; justify-content: center; padding: 8px; font-size: .95rem; }
  .setup-steps { gap: 6px; font-size: .85rem; }
  body:not(.kid) .tabs { position: fixed; bottom: 12px; inset-inline: 14px; max-width: 500px; margin: 0 auto; z-index: 4; padding: 7px; border: 1px solid var(--line); background: #fff; border-radius: 32px; box-shadow: 0 5px 20px #1f293314; }
  body:not(.kid) .wrap:has(.tabs) { padding-bottom: 110px; }
  #app:has(.tabs) .site-footer { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .tabs, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .board { font-size: 1.6rem; }
  .simple-q { font-size: 2rem; }
}
