/* Layout uses logical properties (inline-start/end) so the same rules work left-to-right
   (English, French) and right-to-left (Arabic). */
:root {
  --paper: #F7F9FC;
  --sheet: #FFFFFF;
  --ink: #1B2A4A;
  --ink-2: #4A5878;
  --ink-3: #7A86A0;
  --rule: #D5E2F3;
  --rule-strong: #B5C9E6;
  --pencil: #F2B400;
  --pencil-soft: #FFF3C4;
  --margin: #D94848;
  --margin-soft: #FDE7E7;
  --leaf: #2E8B57;
  --leaf-soft: #E1F3E8;
  --sky: #2F63C9;
  --sky-soft: #E4ECFB;
  --slate-soft: #ECEEF2;
  --line-h: 2.5rem;
  --radius-sm: 6px;
  --radius-lg: 14px;
  /* Arabic glyphs come from IBM Plex Sans Arabic; Latin text keeps the main faces. */
  --display: "Bricolage Grotesque", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --tracking: -0.01em;
  --tracking-hero: -0.025em;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121A2B; --sheet: #182237; --ink: #E8EDF7; --ink-2: #B7C1D6; --ink-3: #8592AD;
    --rule: #26324B; --rule-strong: #34425F; --pencil: #F5C232; --pencil-soft: #3A3218;
    --margin: #F07070; --margin-soft: #3B2026; --leaf: #5CC08A; --leaf-soft: #17352A;
    --sky: #7CA4F2; --sky-soft: #1D2D4F; --slate-soft: #232C40; color-scheme: dark;
  }
}
/* Arabic: one family throughout, no letter-spacing (it breaks joined letters), a little more line height. */
:root:lang(ar) {
  --display: "IBM Plex Sans Arabic", "Bricolage Grotesque", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", "Atkinson Hyperlegible", system-ui, sans-serif;
  --tracking: 0;
  --tracking-hero: 0;
}
:lang(ar) body { line-height: 1.7; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}
body.child { font-size: 1.125rem; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: var(--tracking); }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; }
:lang(ar) h1 { font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 700; }
p { margin: 0 0 .75rem; max-width: 68ch; }
a { color: var(--sky); }
small, .muted { color: var(--ink-3); }
:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; border-radius: 4px; }
/* Hidden above the page until focused, so it never widens the page in either direction. */
.skip { position: absolute; inset-inline-start: 1rem; top: 0; transform: translateY(-120%); background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 50; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.skip:focus { transform: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt-third { margin-top: .35rem; }
.mt-half { margin-top: .5rem; }
.mt-3q { margin-top: .75rem; }
.mt-1 { margin-top: 1rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- header ---------- */
.top {
  background: var(--ink); color: #fff;
  padding: 0 max(16px, calc((100vw - 1120px) / 2));
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .top { background: #0C1220; } }
.top-row { display: flex; align-items: center; gap: 1rem; min-height: 3.75rem; }
.brand { display: flex; align-items: center; gap: .6rem; font: 800 1.2rem var(--display); color: #fff; text-decoration: none; min-width: 0; }
:lang(ar) .brand { font-weight: 700; }
.brand svg { flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { margin-inline-start: auto; display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: #C9D3E6; flex: none; }
.who button { background: transparent; color: #fff; border: 1px solid #45557A; }
.lang-pick select {
  width: auto; background: transparent; color: #fff; border: 1px solid #45557A; border-radius: var(--radius-sm);
  padding: .3rem .5rem; font: 700 .85rem var(--body);
}
.lang-pick option { color: var(--ink); background: var(--sheet); }
@media (max-width: 640px) { .who-name, .who-link > span:first-child { display: none; } .brand { font-size: 1.05rem; } .who { gap: .4rem; } }
.nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
.nav a {
  color: #C9D3E6; text-decoration: none; padding: .55rem .8rem .7rem; white-space: nowrap;
  border-bottom: 4px solid transparent; font-weight: 700; position: relative;
}
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--pencil); }
.nav .badge { margin-inline-start: .35rem; }

/* ---------- layout ---------- */
main:focus { outline: none; }
main { max-width: 1120px; margin: 0 auto; padding: 1.75rem 16px 4rem; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1.5rem; margin-bottom: 1.5rem; }
.page-head p { margin: 0; color: var(--ink-2); }
.page-head .actions { margin-inline-start: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.grid-2.cal-layout { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-2.cal-layout { grid-template-columns: 1fr; } }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.25rem; }
.panel + .panel { margin-top: 1.25rem; }

/* ---------- controls ---------- */
button, .btn {
  font: 700 .95rem var(--body); color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  padding: .55rem .95rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
}
button:hover, .btn:hover { border-color: var(--ink-3); }
button.primary, .btn.primary { background: var(--pencil); border-color: var(--pencil); color: #1B2A4A; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--margin); }
button.ghost { border-color: transparent; background: transparent; }
button.small, a.btn.small, label.btn.small { padding: .3rem .6rem; font-size: .85rem; }
label.btn { display: inline-flex; margin: 0; }
button:disabled { opacity: .55; cursor: progress; }
label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint, h3 .hint { font-weight: 400; color: var(--ink-3); font-size: .85rem; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.plain legend { font-weight: 700; font-size: .92rem; margin-bottom: .3rem; padding: 0; }
input, select, textarea {
  width: 100%; font: 400 1rem var(--body); color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); padding: .6rem .7rem;
}
textarea { min-height: 6rem; resize: vertical; }
textarea.tall { min-height: 9rem; }
/* Emails, usernames, codes and links stay left-to-right; in an Arabic form they sit on the right like the rest. */
[dir="rtl"] input[dir="ltr"] { text-align: right; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--ink); transform: scale(1.15); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 400; margin: .4rem 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--sheet); font-weight: 700; }
.seg button + button { border-inline-start: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin-bottom: 1rem; }
.filters select { width: auto; padding: .4rem .6rem; }
.search-box { max-width: 22rem; }
.inline-field { display: flex; gap: .5rem; }
.error { color: var(--margin); font-weight: 700; margin: .5rem 0; }

/* ---------- chips ---------- */
.chip {
  display: inline-block; font-size: .8rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px;
  background: var(--slate-soft); color: var(--ink-2); white-space: nowrap;
}
.k-test { background: var(--margin-soft); color: var(--margin); }
.k-field_trip { background: var(--leaf-soft); color: var(--leaf); }
.k-reminder, .k-spelling { background: var(--pencil-soft); color: #7A5A00; }
.k-event, .k-homework, .k-reading { background: var(--sky-soft); color: var(--sky); }
.k-project { background: #EFE6FB; color: #6B3FB8; }
.k-no_school { background: var(--slate-soft); color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .k-reminder, :root:not([data-theme="light"]) .k-spelling { color: var(--pencil); }
  :root:not([data-theme="light"]) .k-project { background: #2C2242; color: #C4A6F5; }
}
.legend-due { color: var(--margin); background: transparent; border-inline-start: 3px solid var(--margin); border-radius: 0; }
.lang-chip { background: transparent; border: 1px solid var(--rule-strong); color: var(--ink-2); font-weight: 400; }
.badge { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: 999px; background: var(--margin); color: #fff; font-size: .75rem; font-weight: 700; }

/* ---------- notebook (homework) ---------- */
.notebook {
  --mg: 6.25rem;
  --mg-dir: to right;
  background:
    linear-gradient(var(--mg-dir), transparent calc(var(--mg) - 2px), var(--margin) calc(var(--mg) - 2px), var(--margin) var(--mg), transparent var(--mg)),
    var(--sheet);
  border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden;
}
/* The red margin line sits on the reading-start side: left in English and French, right in Arabic. */
[dir="rtl"] .notebook { --mg-dir: to left; }
.nb-group { display: grid; grid-template-columns: var(--mg) 1fr; border-top: 1px solid var(--rule); }
.nb-group:first-child { border-top: 0; }
.nb-margin { padding-block: .7rem; padding-inline: .9rem .8rem; font-family: var(--display); line-height: 1.15; }
.nb-margin .d { display: block; font-size: 1.6rem; font-weight: 800; }
.nb-margin .w { display: block; font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.nb-margin .rel { display: block; font: 700 .75rem var(--body); color: var(--margin); margin-top: .2rem; }
.nb-margin.past .d, .nb-margin.past .w { color: var(--ink-3); }
.nb-margin.label { font-size: 1rem; font-weight: 800; word-break: break-word; }
.nb-items { padding-inline-start: 1rem; }
.nb-item { border-bottom: 1px solid var(--rule); min-height: var(--line-h); }
.nb-item:last-child { border-bottom: 0; }
.nb-item > button {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .65rem;
  width: 100%; padding-block: .55rem; padding-inline: 0 1rem; min-height: var(--line-h);
}
.nb-item > button:focus-visible { outline: 3px solid var(--pencil); outline-offset: -3px; }
.nb-title { font-weight: 700; }
.nb-meta { color: var(--ink-3); font-size: .88rem; margin-inline-start: auto; }
.nb-detail { padding-inline-end: 1rem; padding-bottom: 1rem; }
.nb-detail .desc { white-space: pre-wrap; }
.words { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; padding: 0; list-style: none; }
.words li { font: 700 1.05rem var(--display); background: var(--pencil-soft); padding: .15rem .6rem; border-radius: var(--radius-sm); }
.files { list-style: none; padding: 0; margin: .5rem 0; }
.files li { display: flex; gap: .5rem; align-items: center; margin: .25rem 0; }
.empty { padding: 2rem 1.25rem; color: var(--ink-2); }
.empty p { margin: 0 auto .75rem; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.cal-head h2 { margin: 0; margin-inline-end: .5rem; min-width: 11ch; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; background: var(--sheet); }
.cal .dow { font-weight: 700; font-size: .8rem; color: var(--ink-3); padding: .45rem .5rem; border-bottom: 1px solid var(--rule); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .day { position: relative; min-height: 6.5rem; padding: .3rem .35rem .45rem; border-inline-end: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.cal .day:nth-child(7n) { border-inline-end: 0; }
.cal .day.out { background: var(--paper); }
.cal .day.out .n { color: var(--ink-3); }
.cal .n { font: 700 .9rem var(--display); display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; }
.cal .day.today .n { background: var(--pencil); color: #1B2A4A; }
.cal .ev {
  display: block; width: 100%; margin-top: .2rem; border: 0; text-align: start;
  font: 700 .78rem/1.35 var(--body); padding: .12rem .35rem; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal .add { position: absolute; top: .3rem; inset-inline-end: .3rem; padding: 0 .35rem; color: var(--ink-3); opacity: 0; }
.cal .day:hover .add, .cal .add:focus-visible { opacity: 1; }
@media (hover: none) { .cal .add { opacity: 1; } }
.cal .ev.due { background: transparent; color: var(--margin); border-inline-start: 3px solid var(--margin); border-radius: 0; }
.cal .ev:focus-visible { outline: 2px solid var(--pencil); }
@media (max-width: 640px) {
  .cal .day { min-height: 4.25rem; padding: .2rem; }
  .cal .ev { font-size: 0; height: .5rem; padding: 0; margin-top: .15rem; }
  .cal .ev.due { height: .5rem; background: var(--margin); }
  .cal .dow { font-size: .7rem; padding: .35rem .25rem; }
}
.legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }

/* ---------- agenda list ---------- */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: grid; grid-template-columns: 4.25rem 1fr; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--rule); }
.agenda li:first-child { border-top: 0; }
.agenda .when { font: 800 .95rem/1.2 var(--display); }
:lang(ar) .agenda .when { font-weight: 700; }
.agenda .when small { display: block; font: 400 .8rem var(--body); }
.agenda .what { min-width: 0; }
.agenda .what strong { display: block; }
.ev-desc { margin: .25rem 0 0; white-space: pre-wrap; }

/* ---------- messages ---------- */
.inbox { display: grid; grid-template-columns: 19rem 1fr; min-height: 32rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; } .inbox.open .threads { display: none; } .inbox:not(.open) .thread { display: none; } }
.threads { border-inline-end: 1px solid var(--rule); overflow-y: auto; max-height: 40rem; }
.threads button { all: unset; box-sizing: border-box; cursor: pointer; display: block; width: 100%; padding: .85rem 1rem; border-bottom: 1px solid var(--rule); }
.threads button[aria-current="true"] { background: var(--sky-soft); }
.threads button:focus-visible { outline: 3px solid var(--pencil); outline-offset: -3px; }
.threads .t-top { display: flex; gap: .5rem; align-items: center; }
.threads .t-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threads .snip { color: var(--ink-3); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { padding: .85rem 1rem; border-bottom: 1px solid var(--rule); display: flex; gap: .5rem; align-items: center; }
.thread-head #back { display: none; }
@media (max-width: 760px) { .thread-head #back { display: inline-flex; } }
.msgs { flex: 1; padding: 1rem; overflow-y: auto; max-height: 30rem; display: flex; flex-direction: column; gap: .75rem; }
/* Bubbles follow the page direction; text inside follows its own language (dir="auto"). */
.msg { max-width: 78%; padding: .65rem .85rem; border-radius: 12px; background: var(--slate-soft); white-space: pre-wrap; overflow-wrap: anywhere; align-self: flex-start; text-align: start; }
.msg.mine { align-self: flex-end; background: var(--sky-soft); }
.msg .subj { font-weight: 700; display: block; }
.msg .meta { display: block; font-size: .75rem; color: var(--ink-3); margin-top: .3rem; white-space: normal; }
.reply { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--rule); }
.reply textarea { min-height: 2.75rem; height: 2.75rem; }
.recips { max-height: 14rem; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: .35rem .75rem; }
.recips .lang-chip { margin-inline-start: .25rem; }
.lang-summary { background: var(--sky-soft); border-radius: var(--radius-sm); padding: .55rem .75rem; font-size: .9rem; color: var(--ink); }

/* ---------- notes (student) ---------- */
.note { border-inline-start: 5px solid var(--pencil); background: var(--sheet); padding: 1rem 1.25rem; border-start-end-radius: var(--radius-lg); border-end-end-radius: var(--radius-lg); }
.note + .note { margin-top: 1rem; }
.note p { white-space: pre-wrap; }

/* ---------- roster / tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .75rem 0; border-top: 1px solid var(--rule); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 12rem; }
.child-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.child-head h2 { margin: 0; flex: 1; }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 3rem; align-items: center; min-height: calc(100vh - 10rem); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; gap: 1.5rem; min-height: 0; } }
.auth-hero h1 { font-size: clamp(2.25rem, 6vw, 3.75rem); line-height: 1.05; letter-spacing: var(--tracking-hero); }
:lang(ar) .auth-hero h1 { line-height: 1.3; font-size: clamp(2rem, 5vw, 3.1rem); }
.auth-hero p { font-size: 1.1rem; color: var(--ink-2); }
.hero-sheet { margin-top: 1.5rem; max-width: 30rem; }
.hero-sheet .nb-group { pointer-events: none; }
.role-tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 1.25rem; }
.role-tabs button { justify-content: center; }
.auth .panel { padding: 1.5rem; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(40rem, calc(100vw - 2rem)); background: var(--sheet); color: var(--ink); box-shadow: 0 20px 60px rgba(10, 20, 40, .35); }
dialog::backdrop { background: rgba(15, 25, 45, .5); }
.dlg-head { display: flex; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule); }
.dlg-head h2 { margin: 0; flex: 1; }
.dlg-body { padding: 1.25rem; max-height: 70vh; overflow-y: auto; }
.dlg-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.25rem; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.dlg-foot .left { margin-inline-end: auto; }
#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(1rem); opacity: 0; pointer-events: none; background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 700; transition: transform .25s ease, opacity .25s ease; z-index: 60; max-width: calc(100vw - 2rem); }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- per-child colours (parents with more than one child) ---------- */
.kid-0 { --kid: #0E7C86; --kid-soft: #DDF3F4; }
.kid-1 { --kid: #C25E00; --kid-soft: #FCEAD8; }
.kid-2 { --kid: #B0357F; --kid-soft: #F8E3F0; }
.kid-3 { --kid: #4B5BD6; --kid-soft: #E6E8FB; }
.kid-4 { --kid: #6B7A12; --kid-soft: #EEF2D5; }
.kid-5 { --kid: #8A4FD8; --kid-soft: #EFE6FB; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kid-0 { --kid: #5FD0D8; --kid-soft: #15373A; }
  :root:not([data-theme="light"]) .kid-1 { --kid: #F2A65A; --kid-soft: #3A2A16; }
  :root:not([data-theme="light"]) .kid-2 { --kid: #EE8CC6; --kid-soft: #3B1F31; }
  :root:not([data-theme="light"]) .kid-3 { --kid: #9AA6F5; --kid-soft: #23284D; }
  :root:not([data-theme="light"]) .kid-4 { --kid: #C3D36A; --kid-soft: #2C3214; }
  :root:not([data-theme="light"]) .kid-5 { --kid: #C4A6F5; --kid-soft: #2C2242; }
}
.kid-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--kid); margin-inline-end: .3rem; vertical-align: .05em; flex: none; }
.kid-tags { display: inline-flex; gap: .25rem; flex-wrap: wrap; }
.agenda .kid-tags { margin-top: .3rem; display: flex; }
.kid-tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: 0 .5rem; border-radius: 999px; background: var(--kid-soft); color: var(--kid); border: 1px solid color-mix(in srgb, var(--kid) 35%, transparent); }
.legend .kid-tag { font-size: .8rem; padding: .1rem .5rem; }
.kid-pick button { gap: .1rem; }
.kid-pick button[aria-pressed="true"] .kid-dot { box-shadow: 0 0 0 2px var(--paper); }
.cal .ev .kid-dot { width: .5rem; height: .5rem; margin-inline-end: .2rem; }
.kid-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.kid-card { flex-direction: column; align-items: flex-start; gap: .4rem; padding: .8rem 1rem; border-radius: var(--radius-lg); border-color: var(--rule); font-weight: 400; text-align: start; }
.kid-card .kid-tag { font-size: .95rem; padding: .1rem .65rem; }
@media (max-width: 640px) { .kid-pick { width: 100%; overflow-x: auto; } .kid-pick button { flex: none; } }

.who-link { color: #C9D3E6; text-decoration: none; display: inline-flex; gap: .6rem; align-items: center; }
.who-link:hover span:first-child { color: #fff; }
.who-acct { border: 1px solid #45557A; border-radius: var(--radius-sm); padding: .2rem .55rem; color: #fff; font-weight: 700; font-size: .85rem; }
.who-link[aria-current="page"] .who-acct { background: var(--pencil); border-color: var(--pencil); color: #1B2A4A; }

/* ---------- private schools / admin ---------- */
.narrow { max-width: 34rem; margin: 2rem auto; }
.narrow h1 { font-size: 1.9rem; }
.todo { margin: 0; padding-inline-start: 1.1rem; }
.todo li { margin: .5rem 0; }
.list > li.is-off { opacity: .7; }
.fam-kids { margin-top: .35rem; display: grid; gap: .25rem; font-size: .93rem; }
.school-chip { background: var(--ink); color: var(--paper); }
.agenda .school-chip { margin-top: .3rem; }
.school-mark { margin-inline-end: .2rem; }
.ann-panel .note { padding-block: .6rem; padding-inline: 1rem 0; }
.lang-checks { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.lang-seg button { min-width: 6.5rem; justify-content: center; }

/* Text people write (messages, homework, notes) can mix languages. Each paragraph takes its
   direction from its own first letter, so an English line and an Arabic line in the same
   message both read and align correctly. */
.msg, .note p, .desc, .ev-desc, .snip [dir="auto"], .nb-detail .desc { unicode-bidi: plaintext; text-align: start; }

/* ---------- medals (badges) ---------- */
.medal {
  --m: #F2B400; --m-soft: #FFF3C4;
  display: inline-grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  font-size: 1.35rem; line-height: 1; background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--m-soft) 19% 100%);
  border: 3px solid var(--m); box-shadow: 0 2px 0 color-mix(in srgb, var(--m) 55%, #000 15%);
}
.medal.sm { width: 2rem; height: 2rem; font-size: 1rem; border-width: 2px; }
.medal.lg { width: 3.6rem; height: 3.6rem; font-size: 1.9rem; border-width: 4px; }
.medal.xl { width: 6.5rem; height: 6.5rem; font-size: 3.4rem; border-width: 6px; }
.bdg-star_of_week { --m: #F2B400; --m-soft: #FFF3C4; }
.bdg-helper, .bdg-team { --m: #2E8B57; --m-soft: #E1F3E8; }
.bdg-kind { --m: #E0699A; --m-soft: #FDE8F0; }
.bdg-effort, .bdg-improver { --m: #D97706; --m-soft: #FEF0DB; }
.bdg-reader, .bdg-speller { --m: #2F63C9; --m-soft: #E4ECFB; }
.bdg-math, .bdg-leader { --m: #6B3FB8; --m-soft: #EFE6FB; }
.bdg-creative, .bdg-listener { --m: #0E7C86; --m-soft: #DDF3F4; }
.bdg-custom { --m: #B0357F; --m-soft: #F8E3F0; }
.mini-shelf { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; }
.list > li > .medal { align-self: flex-start; }

/* badge picker in the teacher's dialog */
.badge-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .4rem; }
.badge-opt { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .88rem; padding: .4rem .5rem; border: 2px solid var(--rule); border-radius: var(--radius-lg); cursor: pointer; margin: 0; }
.badge-opt input { position: absolute; opacity: 0; pointer-events: none; }
.badge-opt:has(input:checked) { border-color: var(--ink); background: var(--pencil-soft); }
.badge-opt:has(input:focus-visible) { outline: 3px solid var(--pencil); outline-offset: 2px; }

/* teacher's class board */
.board { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; }
.board-kid { width: 100%; flex-direction: column; align-items: flex-start; gap: .2rem; border-radius: var(--radius-lg); text-align: start; }
.board-count { font-weight: 400; font-size: .85rem; color: var(--ink-2); }
.chip.quiet { background: transparent; border: 1px dashed var(--rule-strong); color: var(--ink-3); font-weight: 400; }
.star-line { display: flex; align-items: center; gap: .5rem; font-weight: 700; }

/* student's badge shelf */
.shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.badge-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 1rem .6rem; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--sheet); }
.badge-card small { color: var(--ink-3); }
.badge-note { font-size: .9rem; color: var(--ink-2); font-style: italic; }
.big-icon { font-size: 3rem; margin: 0; }

/* achievements */
.achievements { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.ach { display: flex; gap: .75rem; align-items: center; padding: .6rem .7rem; border-radius: var(--radius-lg); border: 1px solid var(--rule); }
.ach > div { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.ach small { color: var(--ink-3); }
.ach-icon { font-size: 1.8rem; filter: grayscale(1); opacity: .45; }
.ach.earned { background: var(--pencil-soft); border-color: transparent; }
.ach.earned .ach-icon { filter: none; opacity: 1; }
.ach .chip { align-self: flex-start; }
.progress { display: block; height: .5rem; border-radius: 999px; background: var(--slate-soft); overflow: hidden; margin-top: .2rem; }
.progress span { display: block; height: 100%; background: var(--pencil); border-radius: 999px; }

/* class shout-outs on the student's home */
.shoutouts { display: grid; gap: .75rem; margin-bottom: 1.5rem; }
.star-banner { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: var(--radius-lg); background: linear-gradient(120deg, #FFF3C4, #FFE08A); color: #1B2A4A; }
.star-banner small { display: block; font-weight: 700; color: #7A5A00; }
.star-banner strong { font: 800 1.5rem var(--display); }
:lang(ar) .star-banner strong { font-weight: 700; }
.cheer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.cheer-list li { display: flex; align-items: center; gap: .45rem; }

/* new-badge celebration */
.celebrate { position: relative; text-align: center; padding: 1rem 0 .5rem; overflow: hidden; }
.celebrate-name { font: 800 1.6rem var(--display); margin: .75rem auto .25rem; }
:lang(ar) .celebrate-name { font-weight: 700; }
.celebrate .medal.xl { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -10%; left: calc(var(--i) * 5.5%); width: .5rem; height: .8rem; border-radius: 2px;
  background: hsl(calc(var(--i) * 47) 85% 60%); animation: fall 1.8s calc(var(--i) * 60ms) ease-in forwards; }
@keyframes pop { from { transform: scale(.3) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fall { to { transform: translateY(26rem) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .celebrate .medal.xl, .confetti i { animation: none; } .confetti { display: none; } }

/* ---------- two-step sign-in ---------- */
.panel.notice { border-color: var(--pencil); background: var(--pencil-soft); }
.steps { padding-inline-start: 1.2rem; margin: 0; display: grid; gap: .9rem; }
.qr { width: 13rem; max-width: 100%; margin: .6rem 0; padding: .4rem; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--rule); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: inline-block; margin-top: .4rem; font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.code-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; max-width: 14rem; font-variant-numeric: tabular-nums; }
.codes { columns: 2; padding-inline-start: 1.4rem; font-size: 1.05rem; line-height: 2; }
.audit > li { padding: .55rem 0; }
@media print {
  body > *:not(dialog) { display: none !important; }
  dialog { position: static; box-shadow: none; width: auto; }
  .dlg-foot, .dlg-head button { display: none; }
}

/* ---------- class themes (student view) ---------- */
/* The theme fills the page around a calm reading area, so homework text always has full contrast. */
.theme-tile { flex-direction: column; gap: .35rem; padding: .4rem; border-radius: var(--radius-lg); font-size: .85rem; }
.theme-tile[aria-checked="true"] { border: 3px solid var(--ink); }
.theme-swatch { display: block; width: 100%; height: 3.25rem; border-radius: 10px; background: var(--theme-bg, var(--paper)); border: 1px solid var(--rule); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .5rem; }

/* The theme sits on a fixed layer behind the page, so it fills the screen on every device
   (iPhones ignore background-attachment: fixed) and never shows seams on long pages. */
body[class*="theme-"]::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--theme-bg); pointer-events: none; }
body[class*="theme-"] .top { background: var(--theme-head); }
body[class*="theme-"] main { background: color-mix(in srgb, var(--paper) 94%, transparent); border-radius: 22px; margin-top: 1.25rem; margin-bottom: 2rem; box-shadow: 0 10px 40px rgba(10, 20, 40, .18); }
@media (max-width: 640px) { body[class*="theme-"] main { border-radius: 16px; margin: .75rem 8px 1.5rem; } }

.theme-space {
  --theme-head: #14123A;
  --theme-bg: radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 1.5px) 0 0 / 90px 90px,
    radial-gradient(circle at 70% 60%, #FFE08A 0 1.5px, transparent 2px) 0 0 / 130px 130px,
    radial-gradient(circle at 40% 80%, #C9D3FF 0 1px, transparent 1.5px) 0 0 / 70px 70px,
    linear-gradient(160deg, #1D1B4B, #3B2C7A 55%, #1B3A6B);
}
.theme-ocean {
  --theme-head: #0B4F6C;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cpath d='M0 20 Q15 8 30 20 T60 20 T90 20 T120 20' fill='none' stroke='%23ffffff' stroke-opacity='.55' stroke-width='3'/%3E%3C/svg%3E") 0 0 / 120px 40px,
    linear-gradient(180deg, #9EE0F5, #4FB3D9 60%, #2C7FB8);
}
.theme-jungle {
  --theme-head: #1F5130;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M20 60 C10 40 25 20 45 15 C40 35 35 50 20 60Z' fill='%232E8B57' fill-opacity='.45'/%3E%3Cpath d='M60 30 C70 45 62 65 45 72 C48 55 52 42 60 30Z' fill='%231F5130' fill-opacity='.35'/%3E%3C/svg%3E") 0 0 / 80px 80px,
    linear-gradient(160deg, #CDEBB4, #8CCB79);
}
.theme-garden {
  --theme-head: #8A2F5B;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cg transform='translate(20 22)'%3E%3Ccircle r='5' cx='0' cy='-7' fill='%23F49AC1'/%3E%3Ccircle r='5' cx='7' cy='0' fill='%23F49AC1'/%3E%3Ccircle r='5' cx='0' cy='7' fill='%23F49AC1'/%3E%3Ccircle r='5' cx='-7' cy='0' fill='%23F49AC1'/%3E%3Ccircle r='4' fill='%23F2B400'/%3E%3C/g%3E%3Ccircle cx='52' cy='52' r='4' fill='%23B7E4A7'/%3E%3C/svg%3E") 0 0 / 70px 70px,
    linear-gradient(160deg, #FFF0F6, #E7F6DC);
}
.theme-dinosaurs {
  --theme-head: #4D5A1E;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cg fill='%236B7A12' fill-opacity='.35'%3E%3Cellipse cx='25' cy='30' rx='9' ry='12'/%3E%3Ccircle cx='16' cy='15' r='3.5'/%3E%3Ccircle cx='25' cy='12' r='3.5'/%3E%3Ccircle cx='34' cy='15' r='3.5'/%3E%3Cellipse cx='62' cy='68' rx='9' ry='12'/%3E%3Ccircle cx='53' cy='53' r='3.5'/%3E%3Ccircle cx='62' cy='50' r='3.5'/%3E%3Ccircle cx='71' cy='53' r='3.5'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 90px 90px,
    linear-gradient(160deg, #F1EBC8, #C9D99A);
}
.theme-rainbow {
  --theme-head: #4A2C82;
  --theme-bg: linear-gradient(135deg, #FFB3B3 0 16%, #FFD59E 16% 32%, #FFF3A6 32% 48%, #BFF0B3 48% 64%, #A8D8FF 64% 80%, #D4B8FF 80% 100%);
}
.theme-winter {
  --theme-head: #2B4C7E;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg stroke='%23ffffff' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M20 10v20M10 20h20M13 13l14 14M27 13L13 27'/%3E%3Cpath d='M60 50v14M53 57h14M55 52l10 10M65 52L55 62'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 80px 80px,
    linear-gradient(180deg, #CFE3F7, #9DC2E8);
}
.theme-desert {
  --theme-head: #8A4B16;
  --theme-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='60'%3E%3Cpath d='M0 45 Q40 20 80 45 T160 45 V60 H0Z' fill='%23E0A15A' fill-opacity='.45'/%3E%3C/svg%3E") 0 100% / 160px 60px,
    linear-gradient(180deg, #FFE7C2, #F6C88A);
}
.theme-plain { --theme-bg: var(--paper); }

/* ---------- demo site ---------- */
.demo-bar { display: flex; align-items: center; justify-content: center; gap: .75rem; flex-wrap: wrap; padding: .4rem 1rem; background: var(--pencil); color: var(--ink); font-size: .9rem; font-weight: 600; text-align: center; }
.demo-bar button { background: var(--ink); color: #fff; border-color: var(--ink); }
.demo-panel { margin-block-end: 1rem; border: 2px solid var(--pencil); }
.demo-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.demo-pick button { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .7rem .8rem; text-align: start; min-height: 3.6rem; }
.demo-pick button small { font-weight: 400; color: var(--ink-2); }
.fb-rate { border: 0; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.fb-rate legend { font-weight: 600; margin-block-end: .4rem; }
.fb-rate label { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .7rem; border: 1px solid var(--rule-strong); border-radius: 999px; cursor: pointer; }
.fb-rate label:has(input:checked) { background: var(--pencil-soft); border-color: var(--pencil); }
.fb-rate input { position: absolute; opacity: 0; pointer-events: none; }
.fb-rate label:focus-within { outline: 2px solid var(--sky); outline-offset: 2px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: .35rem 0 0; }
@media print { .demo-bar { display: none; } }
.demo-switch { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.demo-switch select { font: inherit; font-weight: 600; font-size: .85rem; padding: .25rem .5rem; border-radius: var(--radius-sm); border: 1px solid var(--ink); background: #fff; color: var(--ink); max-width: 16rem; }
@media (max-width: 600px) { .demo-bar > span { flex-basis: 100%; } }

/* ---------- home dashboards ---------- */
.cta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem; margin-block-end: 1.25rem; }
.cta { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; gap: .35rem .75rem; align-items: start; padding: .9rem 1rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); border-inline-start: 5px solid var(--sky); }
.cta.urgent { border-inline-start-color: var(--margin); }
.cta.done { border-inline-start-color: var(--leaf); grid-template-rows: auto; }
.cta-icon { font-size: 1.6rem; line-height: 1; grid-row: span 2; }
.cta-text strong { display: block; line-height: 1.3; }
.cta-text p, .cta.done p { margin: .2rem 0 0; color: var(--ink-2); font-size: .9rem; overflow-wrap: anywhere; }
.cta button { justify-self: start; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .6rem; margin-block-end: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .9rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); color: var(--ink); text-decoration: none; }
.stat:hover { border-color: var(--rule-strong); }
.stat-n { font-family: var(--display); font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.stat-l { font-size: .85rem; color: var(--ink-2); }
.stat.warn .stat-n { color: var(--margin); }
.try-panel { border: 2px dashed var(--pencil); }
.try-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.linklike { background: none; border: 0; padding: .2rem 0; color: var(--sky); text-align: start; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; min-height: 0; }
body[class*="theme-"] .cta, body[class*="theme-"] .stat { background: var(--sheet); }

/* ---------- done ticks, event answers, translations ---------- */
.done-ticks { display: flex; flex-wrap: wrap; gap: .25rem .9rem; padding-inline: .75rem; padding-block-end: .5rem; }
.nb-item > .done-tick { display: inline-flex; padding-inline: .75rem; padding-block-end: .5rem; }
.done-tick { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.done-tick input { width: 1.15rem; height: 1.15rem; accent-color: var(--leaf); }
.nb-item.is-done .nb-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-3); }
.nb-item.is-done .done-tick { color: var(--leaf); }
.done-count { color: var(--leaf); font-weight: 700; }
.ask-box { margin-block-start: .5rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--pencil-soft); display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .9rem; }
.ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; width: 100%; }
.ask-row > span { font-weight: 700; min-width: 4rem; }
.tr-box { margin-block-start: .35rem; }
.small-link { font-size: .85rem; }
.tr-out { margin-block-start: .4rem; padding: .5rem .7rem; border-inline-start: 3px solid var(--sky); background: var(--sky-soft); border-radius: var(--radius-sm); color: var(--ink); }
.tr-out p { margin: 0 0 .25rem; white-space: pre-wrap; }
.tr-out small { color: var(--ink-2); }
.msg .tr-box { text-align: start; }

/* ---------- install banner ---------- */
.install-banner { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; margin-block-end: 1rem; background: var(--sheet); border: 1px solid var(--rule); border-inline-start: 5px solid var(--pencil); border-radius: var(--radius-lg); }
.install-banner img { border-radius: 10px; flex: none; }
.install-banner p { margin: .1rem 0 0; color: var(--ink-2); font-size: .9rem; }
.steps li { margin-block-end: .5rem; }
.msg .tr-box, .msg .tr-out { white-space: normal; }
.msg .tr-out p { white-space: pre-wrap; }

/* The demo bar is always yellow, so its text stays black in light and dark mode. */
.demo-bar, .demo-bar span, .demo-switch, .demo-switch span { color: #000; }
.demo-bar button { background: #000; color: #fff; border-color: #000; }
.demo-switch select { background: #fff; color: #000; border-color: #000; }

/* ---------- privacy ---------- */
.site-foot { text-align: center; padding: 1.5rem 1rem 2rem; font-size: .85rem; color: var(--ink-3); }
.site-foot a { color: var(--ink-2); }
.check.consent { align-items: flex-start; margin: .75rem 0; font-size: .92rem; line-height: 1.4; }
.check.consent input { margin-top: .2rem; }
.privacy-doc h2 { font-size: 1.1rem; margin: 1.25rem 0 .35rem; }
.privacy-doc ul { margin: .25rem 0; padding-inline-start: 1.2rem; }
.privacy-doc li { margin-block-end: .3rem; }
.panel.wide-ish { max-width: 46rem; }

/* ---------- classes, course content, attendance, flex ---------- */
.class-grid, .flex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin-block-end: 1rem; }
.class-grid .panel + .panel, .flex-grid .panel + .panel { margin-top: 0; }
.class-card h2, .flex-card h3 { margin-bottom: .2rem; }
.class-card .muted, .flex-card .muted { margin-bottom: .5rem; }
.flex-card.mine { border-inline-start: 5px solid var(--pencil); }
.meter { height: .45rem; border-radius: 999px; background: var(--slate-soft); overflow: hidden; margin: .4rem 0 .3rem; }
.meter span { display: block; height: 100%; background: var(--sky); border-radius: inherit; }
div.kid-card { display: flex; background: var(--sheet); border: 1px solid var(--rule); }
.kid-card.warn { border-color: var(--pencil); background: var(--pencil-soft); }
.flex-dates { flex-wrap: wrap; }
.unit { position: relative; }
.unit.is-off { border-style: dashed; }
.unit-head { display: flex; gap: .8rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .5rem; }
.unit-head h2 { margin-bottom: .1rem; }
.unit-n { flex: none; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--ink); color: var(--paper); font-weight: 800; font-family: var(--display); }
.unit-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem 1.25rem; margin: .5rem 0; }
.unit-cols ul { margin: 0; padding-inline-start: 1.1rem; }
.unit-cols li { margin-bottom: .25rem; }
.unit h3 { font-size: .95rem; color: var(--ink-2); margin-top: .5rem; }
.reg-head, .reg-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.reg-foot { margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: .9rem; }
.register { list-style: none; margin: 0; padding: 0; }
.register > li { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; padding: .6rem 0; border-top: 1px solid var(--rule); }
.register > li:first-child { border-top: 0; }
.register .grow { flex: 1; min-width: 10rem; }
.att-seg button { min-width: 2.6rem; padding-inline: .5rem; }
.att-seg button[aria-pressed="true"].st-present { background: var(--leaf); color: #fff; }
.att-seg button[aria-pressed="true"].st-absent { background: var(--margin); color: #fff; }
.att-seg button[aria-pressed="true"].st-late { background: var(--pencil); color: #1B2A4A; }
.att-seg button[aria-pressed="true"].st-excused { background: var(--sky); color: #fff; }
.att-note { flex: 0 1 12rem; min-width: 8rem; padding: .35rem .5rem; font-size: .9rem; }
@media (max-width: 640px) { .att-note { flex-basis: 100%; } }
.att-days { list-style: none; margin: 0; padding: 0; }
.att-days > li { display: grid; grid-template-columns: 4.5rem 1fr; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--rule); }
.att-days > li:first-child { border-top: 0; }
.att-days .when { font-weight: 700; display: flex; flex-direction: column; }
.att-days .when small { font-weight: 400; color: var(--ink-2); }
.att-days .list > li { padding: .35rem 0; }
.att-days .list > li.is-new { background: var(--pencil-soft); border-radius: var(--radius-sm); padding-inline: .5rem; }
.list.compact > li { padding: .4rem 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: start; padding: .5rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th { font-size: .8rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.table td:not(:first-child), .table th:not(:first-child) { white-space: nowrap; }
.register .chip { white-space: normal; margin-top: .2rem; }
.page-head .actions select, .page-head .actions input[type="date"] { width: auto; }
.list select { width: auto; max-width: 14rem; }
.unit-head .grow { flex: 1; min-width: 12rem; }
.checklist > li { flex-wrap: nowrap; align-items: flex-start; }
.checklist > li > span { flex: none; width: 1.5rem; }

/* ---------- repeating plans ---------- */
.plans-strip { margin-bottom: 1rem; }
.plans-strip .reg-head h2 { margin: 0; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-item { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: .5rem 1rem; align-items: start; padding: .7rem 0; border-top: 1px solid var(--rule); }
.plan-item:first-child { border-top: 0; }
.plan-item .when { font-weight: 700; display: flex; flex-direction: column; font-family: var(--display); }
.plan-item .when small { font-family: var(--body); font-weight: 400; }
.plan-item.is-past { opacity: .75; }
.plan-item .files { margin: .35rem 0 0; }
.file-btn { cursor: pointer; }
.plan-preview { min-height: 1.5em; font-weight: 600; }
details.panel summary { cursor: pointer; }
@media (max-width: 640px) { .plan-item { grid-template-columns: 3.5rem 1fr; } .plan-item .btn-row { grid-column: 1 / -1; } }

/* ---------- one assignment's page ---------- */
.back-link { margin: 0 0 .5rem; font-weight: 700; }
.assign-kind { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; color: var(--ink-2); font-weight: 700; }
.due-rel { color: var(--margin); font-weight: 700; }
.assign-desc { white-space: pre-wrap; font-size: 1.05rem; line-height: 1.6; }
.words.big li { font-size: 1.25rem; padding: .3rem .8rem; }
.file-cards { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; }
.file-cards li { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.file-ico { font-size: 1.5rem; }
.audio-file { margin-bottom: .75rem; }
.audio-file p { margin: 0 0 .3rem; font-weight: 700; }
.audio-file audio { width: 100%; }
.image-file img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--rule); margin-bottom: .5rem; }
.done-big { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; font-weight: 700; padding: .65rem .8rem; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); cursor: pointer; margin-bottom: .5rem; }
.done-big input { width: 1.4rem; height: 1.4rem; accent-color: var(--leaf); transform: none; }
.done-big:has(input:checked) { background: var(--leaf-soft); border-color: var(--leaf); color: var(--leaf); }
body.child .done-big { font-size: 1.2rem; }

/* ---------- notices ---------- */
.note.notice { border-inline-start-width: 4px; }
.note.notice.p-action { border-inline-start-color: var(--margin); }
.note.notice.p-important { border-inline-start-color: var(--pencil); }
.note.notice.p-info { border-inline-start-color: var(--sky); }
.notice-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.notice-top h3 { margin: 0; }
.acked { color: var(--leaf); font-weight: 700; margin: .4rem 0 0; }
.notice-stats { margin: .35rem 0 0; font-size: .88rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.notice-stats .danger-link { margin-inline-start: auto; }
.notice-stats .linklike { padding-inline: 0; }
.notice-actions { display: flex; justify-content: flex-end; margin: -.5rem 0 .75rem; }
.aud-seg { flex-wrap: wrap; }
.aud-seg label { margin: 0; font-weight: 700; cursor: pointer; }
.aud-seg input { position: absolute; opacity: 0; pointer-events: none; }
.aud-seg span { display: block; padding: .5rem .9rem; background: var(--sheet); }
.aud-seg label + label span { border-inline-start: 1px solid var(--rule-strong); }
.aud-seg input:checked + span { background: var(--ink); color: var(--paper); }
.aud-seg input:focus-visible + span { outline: 3px solid var(--pencil); outline-offset: -3px; }
.danger-link { color: var(--margin); margin-inline-start: .75rem; }
.notice-actions { margin: -.6rem 0 .9rem; }

/* Notice reminders */
.reminded { color: var(--leaf); }

/* Admin "Set up your school" checklist */
.setup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.setup-head h2 { margin-bottom: .1rem; }
.setup-head p { margin: 0; }
.setup-bar { height: 6px; border-radius: 99px; background: var(--rule); overflow: hidden; margin: .75rem 0 .5rem; }
.setup-bar span { display: block; height: 100%; background: var(--sky); border-radius: inherit; transition: width .3s; }
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-steps li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--rule); }
.setup-steps li:first-child { border-top: 0; }
.setup-steps li p { margin: .15rem 0 0; font-size: .9rem; color: var(--ink-2); }
.setup-steps .grow { flex: 1; min-width: 0; }
.setup-done { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 0; }
.setup-done span { font-size: .85rem; color: var(--leaf); background: var(--leaf-soft); border-radius: 99px; padding: .2rem .65rem; }
.setup-tick { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  border: 2px solid var(--rule-strong); color: var(--ink-2); }
.setup-steps li.next .setup-tick { border-color: var(--sky); color: var(--sky); }
@media (max-width: 640px) { .setup-steps li { flex-wrap: wrap; align-items: flex-start; } .setup-steps .grow { flex-basis: calc(100% - 2.6rem); } .setup-steps li > button { margin-inline-start: 2.6rem; } }

/* Grade levels (Settings) */
.level-picks { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; margin: .2rem 0 .6rem 1.7rem; }
.level-picks small { color: var(--ink-3); }
.lv-what { display: grid; gap: .5rem; margin: .4rem 0 1rem; }
.lv-what div { display: grid; grid-template-columns: 11rem 1fr; gap: .8rem; padding: .5rem .7rem; background: var(--slate-soft); border-radius: var(--radius-sm); }
.lv-what dt { font-weight: 700; }
.lv-what dd { margin: 0; color: var(--ink-2); }
@media (max-width: 640px) { .lv-what div { grid-template-columns: 1fr; gap: .1rem; } }

/* Messages: families / students tabs, and student conversations */
.msg-tabs { display: inline-flex; margin: 0 0 1rem; }
.msg-tabs a { padding: .45rem .9rem; text-decoration: none; color: var(--ink); border: 1px solid var(--rule-strong); }
.msg-tabs a:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.msg-tabs a:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); border-inline-start: 0; }
.msg-tabs a[aria-current="page"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.thread-note { margin: 0; max-width: none; padding: .45rem .9rem; font-size: .85rem; color: var(--ink-2); background: var(--pencil-soft); }
.thread-closed { padding: .8rem 1rem; }
.daily-note { margin-top: .8rem; }

/* School options and settings history */
.welcome-panel { border-inline-start: 4px solid var(--pencil); background: var(--pencil-soft); }
.opt-row { padding: .7rem 0; border-top: 1px solid var(--rule); margin: 0; }
.opt-row:first-of-type { border-top: 0; }
.opt-row select { max-width: 22rem; }
table.history td { vertical-align: top; font-size: .9rem; }
table.history td:first-child { white-space: nowrap; }

/* ---------- touch screens (tablets and phones) ----------
   Bigger targets for fingers; mouse users keep the compact sizes. */
@media (pointer: coarse) {
  button.small, a.btn.small, label.btn.small,
  html.ui-fresh button.small, html.ui-fresh a.btn.small, html.ui-fresh label.btn.small { min-height: 40px; padding: .45rem .8rem; }
  .linklike { padding-block: .5rem; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  select, input:not([type="checkbox"]):not([type="radio"]), textarea { font-size: max(16px, 1rem); } /* no zoom-in on focus (iOS) */
}
@media (pointer: coarse) and (min-width: 641px) {
  .cal .ev, html.ui-fresh .cal .ev, html.ui-fresh .cal .ev.chip { padding: .38rem .45rem; margin-top: .3rem; font-size: .82rem; line-height: 1.35; }
}

/* ---------- carpools and hot lunch ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-block-end: .75rem; }
.sec-head h2 { margin: 0; }
.cp-safety { background: var(--pencil-soft); border-color: color-mix(in srgb, var(--pencil) 45%, transparent); }
.cp-safety p { margin: 0; }
.cp-card { display: flex; flex-direction: column; gap: .35rem; }
.cp-card p, .cp-card h3 { margin: 0; }
.cp-card-offer { border-inline-start: 5px solid var(--leaf); }
.cp-card-need { border-inline-start: 5px solid var(--sky); }
.cp-card > button, .cp-card > .actions { margin-top: auto; align-self: flex-start; }
.cp-top { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip.cp-offer { background: var(--leaf-soft); color: var(--leaf); }
.chip.cp-need { background: var(--sky-soft); color: var(--sky); }
.cp-days { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.cp-note { white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
.cp-reqs > li.cp-req { display: flex; justify-content: space-between; gap: .5rem; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--rule); }
.cp-day-picks { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.dlg-msgs { max-height: 18rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: .75rem; }
.lunch-balance h2 { margin-top: 0; }
.lunch-balance.owe { border-inline-start: 5px solid var(--pencil); }
.lunch-kids > li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem 0; border-top: 1px solid var(--rule); }
.lunch-kids .lunch-what { flex: 1 1 12rem; }
.lunch-menu { font-size: .9rem; }
.lunch-items > li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .45rem 0; border-top: 1px solid var(--rule); }
.lunch-items .qty { width: 4.2rem; }
.lunch-total { text-align: end; margin: .5rem 0 0; }
.table tr.past td { color: var(--ink-3); }
.table td.actions { display: flex; gap: .35rem; flex-wrap: wrap; white-space: normal; }
.cp-card select { width: auto; }
.cp-snip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lunch-items > li { flex-wrap: nowrap; }
.lunch-items > li > label { flex: 1; min-width: 0; }
/* Phone menu: space at both ends so the selected tab can always sit in the middle (set by centerNav). */
.nav.nav-centered::before { content: ""; flex: 0 0 var(--nav-pad-start, 0); }
.nav.nav-centered::after { content: ""; flex: 0 0 var(--nav-pad-end, 0); }
/* Simpler interface: "More" menu, "More options" in forms, and the calendar's Show filter. */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: " ▾"; }
details.menu .menu-list { position: absolute; inset-inline-end: 0; top: calc(100% + .3rem); z-index: 20; display: flex; flex-direction: column; min-width: 12rem;
  background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); box-shadow: 0 10px 30px -12px rgba(9, 30, 26, .35); padding: .3rem; }
details.menu .menu-list button { border: 0; background: transparent; text-align: start; justify-content: flex-start; }
details.menu .menu-list button:hover { background: var(--slate-soft); }
details.more-opts { border-top: 1px solid var(--rule); margin-top: .5rem; padding-top: .5rem; }
details.more-opts > summary { cursor: pointer; font-weight: 700; color: var(--ink-2); padding: .3rem 0; }
details.more-opts[open] > summary { margin-bottom: .5rem; }
.cal-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0 0 1rem; }
.cal-filter button.chip { border: 1px solid transparent; cursor: pointer; min-height: 0; }
.cal-filter button.chip.off { background: transparent; color: var(--ink-3); border: 1px dashed var(--rule-strong); text-decoration: line-through; }

/* Families (one or two parents) */
details.menu .menu-list .menu-link { display: block; padding: .5rem .8rem; color: inherit; text-decoration: none; border-radius: 6px; }
details.menu .menu-list .menu-link:hover { background: var(--slate-soft); }
.fam-card { margin-bottom: .8rem; }
.fam-card .fam-parents { margin: 0 0 .4rem; }
.fam-card .fam-parents li { padding-block: .35rem; flex-wrap: wrap; }
.fam-card .fam-kids { margin-top: .3rem; }
.fam-teachers { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.fam-student { border-top: 1px solid var(--rule); padding-top: .5rem; margin-top: .5rem; }
.panel.warn { border-color: var(--pencil); background: var(--pencil-soft); }
.error-text { color: var(--margin); font-weight: 600; }
