/* Reading Buddy: the geex tokens (crm5 names), the shared classes that the kid app and the parent
   portal both use, and the kid app's shell and screens. Colours and fonts are defined only in the
   token blocks below; every rule uses the tokens. Kid-app-only rules sit under body.rb-app or use
   the shell's own .rb- class names, so the portal can load this file too. */

/* The vendor icon fonts point at /fonts/, so declare them again next to this file (the later rule wins). */
@font-face {
  font-display: block;
  font-family: "bootstrap-icons";
  src: url("../vendor/geex/fonts/bootstrap-icons/bootstrap-icons.woff2") format("woff2");
}
@font-face {
  font-family: "Phosphor-Light";
  src: url("../vendor/geex/fonts/phosphor/Phosphor-Light.woff2") format("woff2"),
    url("../vendor/geex/fonts/phosphor/Phosphor-Light.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

/* ---------- Tokens ---------- */
:root {
  /* geex, as in crm5 */
  --crm-primary: #530383;
  --crm-primary-light: #7a12b8;
  --crm-primary-rgb: 83, 3, 131;
  --crm-primary-soft: rgba(83, 3, 131, .08);
  --crm-primary-ink: #530383;
  --crm-bg: #F3F2F7;
  --crm-surface: #fff;
  --crm-border: #e8eaef;
  --crm-heading: #1e1e2d;
  --crm-body-text: #3d3d5c;
  --crm-card-radius: 20px;
  --crm-card-shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --crm-font: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* The rest of crm5's layout theme (its Blade variables; vendor/geex/css/crm-layout.css reads them) */
  --crm-primary-mid: rgba(83, 3, 131, .65);
  --crm-primary-dark: #3c025e;
  --crm-on-primary: #fff;
  --crm-on-primary-light: #fff;
  --crm-link: #530383;
  --crm-dropdown-bg: #fff;
  --crm-dropdown-text: #3d3d5c;
  --crm-sidebar: #16002e;
  --crm-sidebar-text: #fff;
  --crm-sidebar-text-rgb: 255, 255, 255;
  --crm-sidebar-highlight: #2d0060;
  --crm-muted: #6c6c84;

  /* Kid app */
  --rb-tap: 60px;
  --rb-sun: #FFD43B;
  --rb-ok: #13804A;
  --rb-ok-bg: #DDF5E6;
  --rb-almost: #8A5A00;
  --rb-almost-bg: #FFF1C7;
  --rb-miss: #B03F0B;
  --rb-miss-bg: #FFE5D3;

  /* More tokens, for this file and for anyone who needs them */
  --rb-muted: #62627c;
  --rb-on-primary: #fff;
  --rb-sun-ink: #2b2200;
  --rb-sun-glow: rgba(255, 212, 59, .45);
  --rb-ink-rgb: 83, 3, 131;
  --rb-pic-bg: #fff;
  --rb-scrim: rgba(22, 0, 46, .55);
  --rb-lift: 0 10px 28px rgba(30, 30, 45, .14);
  --rb-nav-shadow: 0 -2px 14px rgba(0, 0, 0, .08);
  --rb-side-bg: var(--crm-sidebar);
  --rb-side-strong: var(--crm-sidebar-text);
  --rb-side-ink: rgba(var(--crm-sidebar-text-rgb), .86);
  --rb-side-soft: rgba(var(--crm-sidebar-text-rgb), .42);
  --rb-side-chip: rgba(var(--crm-sidebar-text-rgb), .10);
  --rb-side-active: rgba(var(--crm-sidebar-text-rgb), .20);
  --rb-side-active-chip: rgba(var(--crm-sidebar-text-rgb), .22);
  --rb-side-shadow: 0 8px 32px rgba(0, 0, 0, .18);
  --rb-font-read: "Andika", "Segoe UI", Roboto, Arial, sans-serif;
  --rb-font-hi: "Baloo 2", "Nirmala UI", "Noto Sans Devanagari", "Kohinoor Devanagari", sans-serif;
  --rb-font-ar: "Noto Naskh Arabic", "Geeza Pro", "Segoe UI", Tahoma, serif;
  --rb-font-ml: "Baloo Chettan 2", "Nirmala UI", "Noto Sans Malayalam", "Malayalam Sangam MN", sans-serif;
  --rb-nav-h: 64px;

  /* Bootstrap in geex colours */
  --bs-primary: var(--crm-primary);
  --bs-primary-rgb: var(--crm-primary-rgb);
  --bs-primary-text-emphasis: var(--crm-primary-ink);
  --bs-primary-bg-subtle: var(--crm-primary-soft);
  --bs-primary-border-subtle: rgba(var(--rb-ink-rgb), .3);
  --bs-body-font-family: var(--crm-font);
  --bs-body-bg: var(--crm-bg);
  --bs-body-color: var(--crm-body-text);
  --bs-emphasis-color: var(--crm-heading);
  --bs-heading-color: var(--crm-heading);
  --bs-secondary-color: var(--rb-muted);
  --bs-border-color: var(--crm-border);
  --bs-link-color: var(--crm-primary-ink);
  --bs-link-color-rgb: var(--rb-ink-rgb);
  --bs-link-hover-color: var(--crm-primary-light);
  --bs-link-hover-color-rgb: var(--rb-ink-rgb);
  --bs-focus-ring-color: rgba(var(--rb-ink-rgb), .35);
  color-scheme: light;
}
html[data-bs-theme="dark"] {
  --crm-primary-soft: rgba(215, 176, 247, .14);
  --crm-primary-ink: #d7b0f7;
  --crm-bg: #14141c;
  --crm-surface: #1e1e2a;
  --crm-border: #2b2b39;
  --crm-heading: #f2f0fa;
  --crm-body-text: #cfcde0;
  --crm-card-shadow: 0 2px 14px rgba(0, 0, 0, .45);
  --crm-link: #d7b0f7;
  --crm-dropdown-bg: #24242f;
  --crm-dropdown-text: #d7d7e3;
  --crm-stripe: rgba(255, 255, 255, .03);
  --crm-muted: #9a9ab0;
  --rb-ok: #5FE394;
  --rb-ok-bg: #12402A;
  --rb-almost: #FFD873;
  --rb-almost-bg: #4A3A0C;
  --rb-miss: #FFB37A;
  --rb-miss-bg: #4A260F;
  --rb-muted: #a9a7c0;
  --rb-ink-rgb: 215, 176, 247;
  --rb-scrim: rgba(0, 0, 0, .65);
  --rb-lift: 0 10px 28px rgba(0, 0, 0, .5);
  --rb-nav-shadow: 0 -2px 14px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--crm-bg); color: var(--crm-body-text); font-family: var(--crm-font); }
h1, h2, h3, h4, h5, h6 { color: var(--crm-heading); font-family: var(--crm-font); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--crm-primary-ink); outline-offset: 2px; }
.rb-read { font-family: var(--rb-font-read); }

/* Bootstrap controls in the tokens */
.text-primary { --bs-text-opacity: 1; color: var(--crm-primary-ink) !important; }
.form-control:focus, .form-select:focus {
  border-color: rgba(var(--rb-ink-rgb), .6);
  box-shadow: 0 0 0 .25rem rgba(var(--rb-ink-rgb), .2);
}
.form-check-input:checked { background-color: var(--crm-primary); border-color: var(--crm-primary); }
.form-check-input:focus { border-color: rgba(var(--rb-ink-rgb), .6); box-shadow: 0 0 0 .25rem rgba(var(--rb-ink-rgb), .2); }
.form-range::-webkit-slider-thumb { background-color: var(--crm-primary); }
.form-range::-moz-range-thumb { background-color: var(--crm-primary); }
.form-range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--crm-bg), 0 0 0 .25rem rgba(var(--rb-ink-rgb), .25); }
.form-range:focus::-moz-range-thumb { box-shadow: 0 0 0 1px var(--crm-bg), 0 0 0 .25rem rgba(var(--rb-ink-rgb), .25); }
.pagination { --bs-pagination-color: var(--crm-primary-ink); --bs-pagination-active-bg: var(--crm-primary); --bs-pagination-active-border-color: var(--crm-primary); --bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(var(--rb-ink-rgb), .25); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--crm-primary); }
.list-group { --bs-list-group-active-bg: var(--crm-primary); --bs-list-group-active-border-color: var(--crm-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--crm-primary); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--crm-primary); }

/* Buttons. The plain .btn.rb-btn (and .btn-outline-primary) look comes first, so the primary rule
   after it wins on equal specificity. */
.btn-outline-primary, .rb-btn.btn-outline-primary, .btn.rb-btn {
  --bs-btn-color: var(--crm-primary-ink);
  --bs-btn-border-color: var(--crm-primary-ink);
  --bs-btn-hover-color: var(--rb-on-primary);
  --bs-btn-hover-bg: var(--crm-primary);
  --bs-btn-hover-border-color: var(--crm-primary);
  --bs-btn-focus-shadow-rgb: var(--rb-ink-rgb);
  --bs-btn-active-color: var(--rb-on-primary);
  --bs-btn-active-bg: var(--crm-primary);
  --bs-btn-active-border-color: var(--crm-primary);
  --bs-btn-disabled-color: var(--crm-primary-ink);
  --bs-btn-disabled-border-color: var(--crm-primary-ink);
}
.btn.rb-btn {
  --bs-btn-bg: var(--crm-surface);
  --bs-btn-disabled-bg: var(--crm-surface);
  --bs-btn-disabled-opacity: .45;
  --bs-btn-font-family: var(--crm-font);
  --bs-btn-font-weight: 700;
  --bs-btn-font-size: 1.15rem;
  --bs-btn-line-height: 1.15;
  --bs-btn-padding-x: 22px;
  --bs-btn-padding-y: 8px;
  --bs-btn-border-width: 2px;
  --bs-btn-border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--rb-tap); min-width: var(--rb-tap); max-width: 100%;
  text-align: center; text-decoration: none; white-space: normal; overflow-wrap: anywhere;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.btn-primary, .rb-btn.btn-primary {
  --bs-btn-color: var(--rb-on-primary);
  --bs-btn-bg: var(--crm-primary);
  --bs-btn-border-color: var(--crm-primary);
  --bs-btn-hover-color: var(--rb-on-primary);
  --bs-btn-hover-bg: var(--crm-primary-light);
  --bs-btn-hover-border-color: var(--crm-primary-light);
  --bs-btn-focus-shadow-rgb: var(--rb-ink-rgb);
  --bs-btn-active-color: var(--rb-on-primary);
  --bs-btn-active-bg: var(--crm-primary-light);
  --bs-btn-active-border-color: var(--crm-primary-light);
  --bs-btn-disabled-color: var(--rb-on-primary);
  --bs-btn-disabled-bg: var(--crm-primary);
  --bs-btn-disabled-border-color: var(--crm-primary);
}
/* crm5's geex primary button: the gradient and its soft shadow (crm-layout.css does the same in the portal) */
.btn.btn-primary {
  background-image: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-primary-light) 100%);
  box-shadow: 0 2px 8px rgba(var(--crm-primary-rgb), .25);
}
@media (hover: hover) {
  .btn.btn-primary:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 4px 14px rgba(var(--crm-primary-rgb), .4); }
  .btn.btn-outline-primary:not(:disabled):hover {
    border-color: var(--crm-primary); color: var(--crm-on-primary);
    background-image: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-primary-light) 100%);
  }
}
.btn.rb-btn.rb-danger {
  --bs-btn-color: var(--rb-miss);
  --bs-btn-border-color: var(--rb-miss);
  --bs-btn-hover-color: var(--crm-surface);
  --bs-btn-hover-bg: var(--rb-miss);
  --bs-btn-hover-border-color: var(--rb-miss);
  --bs-btn-active-color: var(--crm-surface);
  --bs-btn-active-bg: var(--rb-miss);
  --bs-btn-active-border-color: var(--rb-miss);
  --bs-btn-disabled-color: var(--rb-miss);
  --bs-btn-disabled-border-color: var(--rb-miss);
}
.btn.rb-btn > i, .btn.rb-btn > .ph-light { font-size: 1.35em; line-height: 1; flex: none; }
.btn.rb-btn:not(:disabled):active { transform: scale(.97); }
.btn.rb-btn.rb-sq { padding: 0; width: var(--rb-tap); }
label.btn.rb-btn:focus-within { outline: 3px solid var(--crm-primary-ink); outline-offset: 2px; }
/* Listening: a warm, pulsing button */
.btn.rb-btn.rb-live {
  --bs-btn-color: var(--crm-surface);
  --bs-btn-bg: var(--rb-miss);
  --bs-btn-border-color: var(--rb-miss);
  --bs-btn-hover-color: var(--crm-surface);
  --bs-btn-hover-bg: var(--rb-miss);
  --bs-btn-hover-border-color: var(--rb-miss);
  --bs-btn-active-color: var(--crm-surface);
  --bs-btn-active-bg: var(--rb-miss);
  --bs-btn-active-border-color: var(--rb-miss);
  animation: rb-pulse 1.2s infinite;
}
@keyframes rb-pulse { 50% { transform: scale(1.06); } }
/* A tapped button on a touch screen should not stay coloured as if it were chosen. */
@media (hover: none) {
  .btn.rb-btn:hover { color: var(--bs-btn-color); background-color: var(--bs-btn-bg); border-color: var(--bs-btn-border-color); }
}

/* ---------- Shared classes (kid app and portal) ---------- */
.card {
  --bs-card-bg: var(--crm-surface);
  --bs-card-color: var(--crm-body-text);
  --bs-card-border-color: var(--crm-border);
  --bs-card-border-radius: var(--crm-card-radius);
  --bs-card-inner-border-radius: calc(var(--crm-card-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-title-color: var(--crm-heading);
  background-color: var(--crm-surface);
  border-color: var(--crm-border);
  border-radius: var(--crm-card-radius);
  box-shadow: var(--crm-card-shadow);
}

.rb-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--rb-grid-min, 150px)), 1fr));
}
.rb-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.rb-row.rb-start { justify-content: flex-start; }
.rb-row:not(:has(> :not([hidden]))) { display: none; }
.rb-stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.rb-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-width: 0; min-height: 132px; padding: 16px 12px;
  border: 1px solid var(--crm-border); border-radius: var(--crm-card-radius);
  background: var(--crm-surface); color: var(--crm-heading); box-shadow: var(--crm-card-shadow);
  font-family: var(--crm-font); font-weight: 700; font-size: 1.2rem; line-height: 1.2;
  text-align: center; text-decoration: none; overflow-wrap: anywhere;
  cursor: pointer; touch-action: manipulation;
}
button.rb-tile { -webkit-appearance: none; appearance: none; }
.rb-tile:active { transform: scale(.98); }
.rb-tile.on, .rb-tile[aria-pressed="true"], .rb-tile[aria-current] { border: 2px solid var(--crm-primary-ink); background: var(--crm-primary-soft); }
@media (hover: hover) { .rb-tile:hover { border-color: rgba(var(--rb-ink-rgb), .45); color: var(--crm-heading); } }

.rb-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; max-width: 100%; padding: 4px 12px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--crm-primary-soft); color: var(--crm-primary-ink);
  font-family: var(--crm-font); font-weight: 600; font-size: .95rem; line-height: 1.2;
}
button.rb-chip, a.rb-chip, label.rb-chip {
  min-height: var(--rb-tap); padding: 8px 20px;
  border: 2px solid var(--crm-border); background: var(--crm-surface); color: var(--crm-heading);
  font-size: 1.1rem; text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.rb-chip.on, .rb-chip[aria-pressed="true"], .rb-chip[aria-checked="true"], .rb-chip[aria-current], label.rb-chip:has(input:checked) {
  border-color: var(--crm-primary); background: var(--crm-primary); color: var(--rb-on-primary);
}
label.rb-chip:has(input:focus-visible) { outline: 3px solid var(--crm-primary-ink); outline-offset: 2px; }

.rb-big { font-family: var(--rb-font-read); font-weight: 700; font-size: clamp(44px, 10vw, 84px); line-height: 1.15; color: var(--crm-heading); min-width: 0; overflow-wrap: anywhere; }
.rb-big[lang="ar"] { font-size: calc(1.15 * clamp(44px, 10vw, 84px)); line-height: 1.6; }
.rb-pic {
  display: grid; place-items: center; justify-self: center; flex: none;
  width: 150px; height: 150px; overflow: hidden;
  border: 1px solid var(--crm-border); border-radius: 20px; background: var(--rb-pic-bg);
  font-size: 68px; line-height: 1;
}
.rb-pic img { width: 100%; height: 100%; object-fit: contain; }
.rb-note { margin: 0; font-size: .95rem; line-height: 1.45; color: var(--rb-muted); }
.rb-status { margin: 0; min-height: 1.4em; font-family: var(--crm-font); font-weight: 700; font-size: 1.2rem; line-height: 1.4; color: var(--rb-muted); text-align: center; }
.rb-badge {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 999px; background: var(--crm-primary); color: var(--rb-on-primary);
  font-family: var(--crm-font); font-weight: 700; font-size: .9rem; line-height: 1;
}
.rb-new {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px;
  border-radius: 999px; background: var(--rb-sun); color: var(--rb-sun-ink);
  font-family: var(--crm-font); font-weight: 800; font-size: .8rem; line-height: 1; letter-spacing: .04em; text-transform: uppercase;
}
.rb-new:empty::after { content: "New"; }

/* Big tick box: <label class="rb-check"><input type="checkbox"> Text</label>, or a button with aria-pressed */
.rb-check {
  display: flex; align-items: center; gap: 14px; width: 100%; min-width: 0; min-height: var(--rb-tap);
  padding: 10px 16px; border: 2px solid var(--crm-border); border-radius: 18px;
  background: var(--crm-surface); color: var(--crm-heading);
  font-family: var(--crm-font); font-weight: 600; font-size: 1.15rem; line-height: 1.3; text-align: start;
  cursor: pointer; touch-action: manipulation;
}
.rb-check input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; margin: 0; border: 3px solid var(--crm-primary-ink); border-radius: 12px;
  background: var(--crm-surface); cursor: pointer;
}
.rb-check input[type="checkbox"]:checked { border-color: var(--rb-ok); background: var(--rb-ok); }
.rb-check input[type="checkbox"]:checked::after {
  content: ""; width: 12px; height: 22px; border: solid var(--crm-surface); border-width: 0 5px 5px 0;
  transform: translateY(-2px) rotate(45deg);
}
.rb-check input[type="checkbox"]:focus-visible { outline: 3px solid var(--crm-primary-ink); outline-offset: 2px; }
button.rb-check::before, .rb-check[role="checkbox"]::before {
  content: ""; flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border: 3px solid var(--crm-primary-ink); border-radius: 12px;
  color: var(--crm-surface); font-size: 26px; font-weight: 800; line-height: 1;
}
button.rb-check.on::before, button.rb-check[aria-pressed="true"]::before, .rb-check[aria-checked="true"]::before {
  content: "✓"; border-color: var(--rb-ok); background: var(--rb-ok);
}
.rb-check:has(input:checked), .rb-check.on, .rb-check[aria-checked="true"], .rb-check[aria-pressed="true"] {
  border-color: var(--rb-ok); background: var(--rb-ok-bg);
}

/* Stepping stones, a wrapping row: <ol class="rb-steps"><li class="done">…<li class="current">…<li>…</ol>.
   Each li gets a numbered stone (ticked when done, glowing when current). The homework and school-check
   paths draw their own stones inside each li, so they don't get a second one. */
.rb-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; counter-reset: rb-step; }
.rb-steps > li { counter-increment: rb-step; position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: var(--rb-tap); }
.rb-steps > li::before {
  content: counter(rb-step); position: relative; z-index: 1; flex: none; display: grid; place-items: center;
  width: 52px; height: 52px; border: 3px solid var(--crm-border); border-radius: 50%;
  background: var(--crm-surface); color: var(--rb-muted);
  font-family: var(--crm-font); font-weight: 800; font-size: 1.25rem; line-height: 1;
}
.rb-steps:is(.hw-steps, .sd-steps) > li::before { content: none; display: none; }
.rb-steps > li.done::before, .rb-steps > li.is-done::before, .rb-steps > li[data-state="done"]::before {
  content: "✓"; border-color: var(--rb-ok); background: var(--rb-ok); color: var(--crm-surface);
}
.rb-steps > li.current::before, .rb-steps > li.is-current::before, .rb-steps > li[aria-current]::before {
  border-color: var(--rb-sun); background: var(--rb-sun); color: var(--rb-sun-ink);
  animation: rb-glow 1.6s ease-in-out infinite;
}
@keyframes rb-glow { 0%, 100% { box-shadow: 0 0 0 4px var(--rb-sun-glow); } 50% { box-shadow: 0 0 0 11px var(--rb-sun-glow); } }

/* Word buttons in a sentence */
.w { margin: 0; padding: 0 .08em; border: 0; border-radius: .2em; background: none; color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
.w.on { background: var(--rb-sun); color: var(--rb-sun-ink); }
.w.ok { color: var(--rb-ok); }
.w.almost { background: var(--rb-almost-bg); color: var(--rb-almost); }
.w.bad { background: var(--rb-miss-bg); color: var(--rb-miss); text-decoration: underline wavy; text-underline-offset: .15em; }
.w.mark { background: var(--rb-miss-bg); color: var(--rb-miss); outline: 3px dashed var(--rb-miss); }

/* ---------- Kid app shell ---------- */
body.rb-app {
  min-height: 100vh; min-height: 100dvh; margin: 0;
  font-size: 1.125rem; line-height: 1.5; -webkit-tap-highlight-color: transparent;
}

.rb-main {
  --rb-main-top: max(12px, env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 1200px; margin: 0 auto;
  padding: var(--rb-main-top) max(16px, env(safe-area-inset-right))
    calc(var(--rb-nav-h) + env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
}

/* Floating sidebar (992px and wider), after crm5's layouts/app.blade.php */
.rb-side { display: none; }
.rb-side-brand {
  position: sticky; top: 0; z-index: 1; flex: none;
  display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 18px 16px 16px;
  border-bottom: 1px solid var(--rb-side-chip); background: var(--rb-side-bg);
  color: var(--rb-side-strong); text-decoration: none;
}
.rb-side-brand:hover { color: var(--rb-side-strong); }
.rb-side-logo, .rb-top-logo, .rb-boot-logo {
  display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-light)); color: var(--rb-on-primary);
}
.rb-side-logo { width: 38px; height: 38px; border-radius: 11px; font-size: 1.3rem; }
.rb-side-text { min-width: 0; }
.rb-side-name { display: block; font-weight: 800; font-size: 1.05rem; line-height: 1.15; color: var(--rb-side-strong); }
.rb-side-sub { display: block; overflow: hidden; font-weight: 500; font-size: .85rem; color: var(--rb-side-soft); text-overflow: ellipsis; white-space: nowrap; }
.rb-side-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px 10px 16px; }
.rb-side-item {
  display: flex; align-items: center; gap: 12px; min-height: var(--rb-tap); padding: 10px 12px;
  border-radius: 12px; color: var(--rb-side-ink); font-weight: 500; font-size: 1.05rem; line-height: 1.2;
  text-decoration: none; transition: background .14s, color .14s, transform .12s;
}
.rb-side-item:hover { background: var(--rb-side-chip); color: var(--rb-side-strong); transform: translateX(2px); }
.rb-side-item.active { background: var(--rb-side-active); color: var(--rb-side-strong); font-weight: 600; }
.rb-side-item:focus-visible { outline-color: var(--rb-side-strong); }
.rb-side-item > span:not(.rb-side-icon):not(.rb-badge) { flex: 1; min-width: 0; text-align: left; }
.rb-side-icon {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px;
  border-radius: 8px; background: var(--rb-side-chip); font-size: 1.05rem; line-height: 1;
}
.rb-side-item.active .rb-side-icon, .rb-side-item:hover .rb-side-icon { background: var(--rb-side-active-chip); }
.rb-side-item .rb-badge { background: var(--rb-sun); color: var(--rb-sun-ink); }
/* crm5's .s-nav-section label, a little bigger for young readers */
.rb-side-section {
  padding: 12px 12px 4px; color: var(--rb-side-soft);
  font-weight: 700; font-size: .78rem; letter-spacing: .09em; text-transform: uppercase;
}
.rb-side-section:first-child { padding-top: 4px; }

/* Bottom nav (below 992px), after crm5's crm-mobile.css .crm-bottom-nav */
.rb-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex;
  height: calc(var(--rb-nav-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top: 1px solid var(--crm-border); background: var(--crm-surface); box-shadow: var(--rb-nav-shadow);
}
.rb-bottom a {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--rb-muted); font-weight: 600; font-size: .8rem; line-height: 1.1; text-decoration: none;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.rb-bottom a > i { position: relative; z-index: 1; font-size: 1.6rem; line-height: 1; }
.rb-bottom a > span { position: relative; z-index: 1; max-width: 100%; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-bottom a.active { color: var(--crm-primary-ink); }
/* crm5's active tab: a soft pill behind the icon that grows in */
.rb-bottom a::before {
  content: ""; position: absolute; top: 6px; left: 50%; z-index: 0; width: 58px; height: 32px; border-radius: 16px;
  background: var(--crm-primary-soft); opacity: 0; transform: translateX(-50%) scaleX(.35);
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, 0, 0, 1);
}
.rb-bottom a.active::before { opacity: 1; transform: translateX(-50%) scaleX(1); }
.rb-bottom a.active > i { transform: scale(1.08); }
.rb-bottom a:active > i { transform: scale(.9); }

/* Top bar: crm5's .topbar, sticky, and joined to the top edge (rounded below) unless the viewing banner is above it */
.rb-top {
  position: sticky; top: 0; z-index: 97;
  display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 76px; padding: 8px;
  border: 1px solid var(--crm-border); border-radius: var(--crm-card-radius);
  background: var(--crm-surface); box-shadow: var(--crm-card-shadow);
}
.rb-viewing[hidden] + .rb-top {
  margin-top: calc(-1 * var(--rb-main-top)); padding-top: max(8px, env(safe-area-inset-top));
  border-top: 0; border-radius: 0 0 16px 16px;
}
.rb-top-logo { width: var(--rb-tap); height: var(--rb-tap); border-radius: 16px; font-size: 1.8rem; text-decoration: none; }
.rb-top-logo:hover { color: var(--rb-on-primary); }
.rb-title {
  flex: 1 1 auto; min-width: 0; margin: 0 0 0 6px; overflow: hidden;
  color: var(--crm-heading); font-weight: 800; font-size: clamp(1.3rem, 3.4vw, 1.75rem); line-height: 1.25;
  text-overflow: ellipsis; white-space: nowrap;
}
.rb-points {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: var(--rb-tap); padding: 0 18px;
  border-radius: 999px; background: var(--rb-sun); color: var(--rb-sun-ink);
  font-weight: 800; font-size: 1.3rem; line-height: 1; text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
}
.rb-points:hover { color: var(--rb-sun-ink); }
.rb-points:active { transform: scale(.96); }
.rb-points small { font-size: .7em; font-weight: 700; opacity: .8; }
.rb-hold { position: relative; flex: none; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rb-hold .rb-fill { position: absolute; inset: 0; background: var(--rb-sun); opacity: .55; transform: scaleX(0); transform-origin: left; pointer-events: none; }
.rb-hold.holding .rb-fill { transform: scaleX(1); transition: transform 1s linear; }
.rb-hold > span { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.rb-voice { flex: none; }

/* Banners */
.rb-viewing {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 8px 8px 18px;
  border-radius: var(--crm-card-radius); background: var(--crm-primary); color: var(--rb-on-primary); font-weight: 600;
}
.rb-viewing > span { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.rb-viewing b { font-weight: 800; }
.rb-viewing .btn.rb-btn { --bs-btn-bg: var(--crm-surface); --bs-btn-border-color: var(--crm-surface); --bs-btn-color: var(--crm-primary-ink); --bs-btn-hover-bg: var(--crm-surface); --bs-btn-hover-color: var(--crm-primary-ink); --bs-btn-hover-border-color: var(--crm-surface); }
.rb-banner {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 16px;
  border-radius: 16px; background: var(--rb-almost-bg); color: var(--rb-almost); font-weight: 600; line-height: 1.35;
}
.rb-banner > i { flex: none; font-size: 1.5rem; }

/* ---------- Kid app screens ---------- */
.rb-screen { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rb-hello { margin: 4px 0 0; color: var(--crm-heading); font-weight: 800; font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.15; }
.rb-h2 { margin: 0; color: var(--crm-heading); font-weight: 800; font-size: clamp(1.3rem, 3.4vw, 1.7rem); line-height: 1.2; }
.rb-center { text-align: center; }
.rb-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.rb-cards:not(:has(.rb-slot > *)) { display: none; }
.rb-slot { display: contents; }
.rb-grid.rb-tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
/* crm5's stat-card icon: a soft rounded tile, kid-sized */
.rb-tile-icon {
  display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 4px;
  border-radius: 18px; background: var(--crm-primary-soft); color: var(--crm-primary-ink);
  font-size: 2.4rem; line-height: 1;
}
.rb-tile-icon[lang] { font-weight: 700; }
.rb-tile-sub { color: var(--rb-muted); font-weight: 600; font-size: .95rem; }
.rb-tile .rb-badge { background: var(--rb-sun); color: var(--rb-sun-ink); }
.rb-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 8px; }

/* Lesson cards */
.rb-lessons { --rb-grid-min: 210px; }
.rb-lesson {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 180px; padding: 18px;
  border: 1px solid var(--crm-border); border-radius: var(--crm-card-radius);
  background: var(--crm-surface); color: var(--crm-heading); box-shadow: var(--crm-card-shadow);
  text-decoration: none; touch-action: manipulation;
}
.rb-lesson:hover { color: var(--crm-heading); }
.rb-lesson:active { transform: scale(.98); }
.rb-lesson-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rb-lesson-cover { font-size: 48px; line-height: 1; }
.rb-lesson-title { flex: 1; font-weight: 800; font-size: 1.3rem; line-height: 1.25; overflow-wrap: anywhere; }
.rb-lesson-meta { color: var(--rb-muted); font-weight: 700; font-size: 1rem; }
.rb-lesson.rb-add { align-items: center; justify-content: center; border: 3px dashed var(--crm-border); background: transparent; box-shadow: none; color: var(--crm-primary-ink); text-align: center; }
.rb-lesson.rb-add .rb-lesson-cover { font-size: 52px; }
.rb-bar { height: 10px; border-radius: 999px; background: var(--crm-border); overflow: hidden; flex: none; }
.rb-bar > i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--rb-sun); transition: width .3s; }

/* Screen heading with a back button */
.rb-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rb-head h2 { flex: 1; min-width: 0; margin: 0; font-weight: 800; font-size: clamp(1.3rem, 3.6vw, 1.8rem); line-height: 1.25; overflow-wrap: anywhere; }
.rb-count { color: var(--rb-muted); font-weight: 700; white-space: nowrap; }

/* Reading page. Its height is capped so the page, the status line and the reading buttons always fit on the
   screen together; a long sentence scrolls inside the page (auto margins centre it only when there is room). */
.rb-page {
  display: flex; flex-direction: column; min-width: 0; min-height: 200px; padding: clamp(18px, 4vw, 40px);
  max-height: max(150px, calc(100vh - 540px)); max-height: max(150px, calc(100dvh - 540px));
  overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--crm-border); border-radius: 26px; background: var(--crm-surface); box-shadow: var(--crm-card-shadow);
}
@media (min-width: 600px) {
  .rb-page { max-height: max(150px, calc(100vh - 440px)); max-height: max(150px, calc(100dvh - 440px)); }
}
.rb-sent { margin: auto 0; color: var(--crm-heading); font-family: var(--rb-font-read); font-weight: 700; font-size: clamp(28px, 5.5vw, 50px); line-height: 1.6; text-align: start; overflow-wrap: anywhere; }
.rb-sent[lang="hi"], .rb-sent[lang="ml"] { line-height: 1.75; }
.rb-sent[lang="ar"] { font-size: calc(1.15 * clamp(28px, 5.5vw, 50px)); line-height: 1.95; }
.rb-chunk { white-space: nowrap; }
.rb-panel {
  display: grid; gap: 12px; min-width: 0; padding: 18px;
  border: 1px solid var(--crm-border); border-radius: var(--crm-card-radius); background: var(--crm-surface); box-shadow: var(--crm-card-shadow);
}
.rb-prac { justify-items: center; text-align: center; }
.rb-lbl { color: var(--rb-muted); font-weight: 800; font-size: .8rem; line-height: 1.2; letter-spacing: .06em; text-transform: uppercase; }

/* Forms */
.rb-field { display: grid; gap: 6px; min-width: 0; margin: 0; color: var(--rb-muted); font-weight: 700; }
.rb-field input:not([type="range"]):not([type="radio"]):not([type="checkbox"]), .rb-field select, .rb-field textarea {
  width: 100%; min-height: var(--rb-tap); padding: 10px 14px;
  border: 2px solid var(--crm-border); border-radius: 14px; background: var(--crm-surface); color: var(--crm-heading);
  font-family: var(--rb-font-read); font-weight: 400; font-size: 1.1rem; line-height: 1.4;
}
.rb-field textarea { min-height: 220px; resize: vertical; }
.rb-field input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--crm-primary); }
fieldset.rb-field { padding: 0; border: 0; }
.rb-field legend { float: none; width: auto; margin: 0 0 6px; padding: 0; font-size: inherit; font-weight: 700; line-height: inherit; }
.rb-choice { display: flex; align-items: center; gap: 12px; min-height: var(--rb-tap); margin: 0; color: var(--crm-heading); font-weight: 500; cursor: pointer; }
.rb-choice input { flex: none; width: 28px; height: 28px; margin: 0; accent-color: var(--crm-primary); }

/* Tricky words */
.rb-tlist { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.rb-tlist li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; padding: 10px 12px 10px 18px;
  border: 1px solid var(--crm-border); border-radius: var(--crm-card-radius); background: var(--crm-surface); box-shadow: var(--crm-card-shadow);
}
.rb-tword {
  flex: 1 1 150px; min-width: 0; min-height: var(--rb-tap); padding: 0; border: 0; background: none;
  color: var(--crm-heading); font-family: var(--rb-font-read); font-weight: 700; font-size: clamp(26px, 5vw, 36px); line-height: 1.3;
  text-align: start; overflow-wrap: anywhere; cursor: pointer;
}
.rb-tword[lang="ar"] { font-size: calc(1.15 * clamp(26px, 5vw, 36px)); }
.rb-times { color: var(--rb-muted); font-weight: 700; white-space: nowrap; }
.rb-empty { padding: 32px 16px; text-align: center; }

/* Dialogs */
.rb-back {
  position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--rb-scrim);
}
.rb-dialog.card {
  display: grid; gap: 12px; width: min(560px, 100%); max-height: 92vh; max-height: calc(100dvh - 32px);
  padding: 20px; overflow: auto; overscroll-behavior: contain; box-shadow: var(--rb-lift);
}
.rb-dialog p { margin: 0; }
.rb-dialog .rb-text { font-size: 1.25rem; color: var(--crm-heading); overflow-wrap: anywhere; }
.rb-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.rb-dialog-head h2 { margin: 0; min-width: 0; font-weight: 800; font-size: 1.6rem; line-height: 1.2; overflow-wrap: anywhere; }
.rb-dialog hr { width: 100%; margin: 4px 0; border: 0; border-top: 2px solid var(--crm-border); opacity: 1; }
.rb-glist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rb-glist li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.rb-glist li > span { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.rb-dl { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.rb-dl dt { color: var(--rb-muted); font-weight: 600; }
.rb-dl dd { margin: 0; color: var(--crm-heading); font-weight: 600; overflow-wrap: anywhere; }
.rb-warn { padding: 10px 14px; border-radius: 14px; background: var(--rb-almost-bg); color: var(--rb-almost); }
.rb-cw { flex: 1; }

/* Pop-up alerts */
.rb-alert.card { justify-items: center; text-align: center; animation: rb-pop .35s ease-out; }
.rb-alert-icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 28px; background: var(--crm-primary-soft); font-size: 48px; line-height: 1; }
.rb-alert-title { margin: 0; font-weight: 800; font-size: 1.6rem; line-height: 1.2; overflow-wrap: anywhere; }
.rb-alert-body { font-size: 1.2rem; color: var(--crm-body-text); white-space: pre-line; overflow-wrap: anywhere; }
@keyframes rb-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

/* Approve-this-tablet screen, the start screen and the toast */
.rb-device, .rb-boot {
  position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 16px; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); background: var(--crm-bg); text-align: center;
}
.rb-device { z-index: 1070; }
.rb-device .card { display: grid; justify-items: center; gap: 16px; width: min(560px, 100%); padding: 28px 20px; }
.rb-device h2 { margin: 0; font-weight: 800; font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.2; }
.rb-device-icon { color: var(--crm-primary-ink); font-size: 76px; line-height: 1; }
.rb-boot { z-index: 1080; }
.rb-boot-logo { width: 88px; height: 88px; border-radius: 26px; font-size: 48px; }
.rb-boot p { max-width: 28em; margin: 0; color: var(--crm-heading); font-weight: 700; font-size: 1.25rem; line-height: 1.4; }
.rb-dots { display: inline-flex; gap: 8px; }
.rb-dots > span { width: 12px; height: 12px; border-radius: 50%; background: var(--crm-primary-ink); animation: rb-dot 1.2s infinite ease-in-out; }
.rb-dots > span:nth-child(2) { animation-delay: .15s; }
.rb-dots > span:nth-child(3) { animation-delay: .3s; }
@keyframes rb-dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.rb-toast {
  position: fixed; left: 50%; bottom: calc(var(--rb-nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 1060;
  max-width: calc(100% - 32px); padding: 12px 22px; transform: translateX(-50%);
  border-radius: 999px; background: var(--crm-heading); color: var(--crm-surface); box-shadow: var(--rb-lift);
  font-weight: 700; font-size: 1.1rem; line-height: 1.3; text-align: center; pointer-events: none;
}
.rb-soon { display: grid; justify-items: center; gap: 12px; padding: 32px 20px; text-align: center; }
.rb-soon .rb-big { font-size: 64px; }

/* Phones */
@media (max-width: 599px) {
  .btn.rb-btn { --bs-btn-padding-x: 16px; --bs-btn-font-size: 1.05rem; }
  .rb-top .rb-hold, .rb-top .rb-voice { width: var(--rb-tap); padding: 0; }
  .rb-top .rb-hold .rb-hold-label, .rb-top .rb-voice .rb-voice-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rb-points { padding: 0 14px; font-size: 1.15rem; }
  .rb-top-logo { display: none; }
  .rb-lessons { --rb-grid-min: 150px; }
  .rb-lesson { min-height: 160px; padding: 14px; }
  .rb-lesson-title { font-size: 1.15rem; }
  .rb-lesson-cover { font-size: 40px; }
}

/* Short screens (a landscape phone, or a tablet at 150% zoom): keep the reading buttons in view */
@media (max-height: 600px) {
  .rb-main { --rb-main-top: max(8px, env(safe-area-inset-top)); gap: 10px; }
  .rb-tile-icon { width: 60px; height: 60px; font-size: 2rem; }
  .rb-top { min-height: 66px; padding: 2px 8px; }
  .rb-page { min-height: 110px; padding: 14px 22px; max-height: max(110px, calc(100vh - 385px)); max-height: max(110px, calc(100dvh - 385px)); }
  .rb-sent { font-size: clamp(26px, min(5.5vw, 8vh), 50px); }
  .rb-sent[lang="ar"] { font-size: calc(1.15 * clamp(26px, min(5.5vw, 8vh), 50px)); }
}

/* Wide screens: the floating sidebar replaces the bottom nav */
@media (min-width: 992px) {
  .rb-side {
    position: fixed; top: 16px; left: 16px; bottom: 16px; z-index: 100; width: 262px;
    display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto;
    border-radius: 20px; background: var(--rb-side-bg); box-shadow: var(--rb-side-shadow);
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  }
  .rb-bottom { display: none; }
  .rb-top-logo { display: none; }
  .rb-main { --rb-main-top: 16px; max-width: 1160px; margin: 0 auto 0 294px; padding: var(--rb-main-top) 24px 32px 0; }
  .rb-toast { bottom: 24px; left: calc(50% + 147px); }
  .rb-page { max-height: max(200px, calc(100vh - 390px)); max-height: max(200px, calc(100dvh - 390px)); }
}

@media (prefers-reduced-motion: reduce) {
  .btn.rb-btn.rb-live, .rb-steps > li::before, .rb-dots > span, .rb-alert.card { animation: none !important; }
  .rb-hold.holding .rb-fill, .rb-bar > i, .rb-side-item { transition: none; }
}

/* Fonts by language, last and with two attribute selectors so that a class rule never hides them.
   The 1.15x size has no specificity, so a rule that sets its own size keeps it. */
[lang="hi"][lang] { font-family: var(--rb-font-hi); }
[lang="ar"][lang] { font-family: var(--rb-font-ar); }
[lang="ml"][lang] { font-family: var(--rb-font-ml); }
:where([lang="ar"]) { font-size: 1.15em; line-height: 1.75; }
:where([lang="ar"] [lang="ar"]) { font-size: 1em; }
