/* ============ Fonts (self-hosted) ============ */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/plex-arabic-400.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/plex-arabic-500.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/plex-arabic-600.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/plex-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/plex-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/plex-latin-500.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/plex-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/plex-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Kufi'; font-weight: 700; font-display: swap; src: url(/fonts/kufi-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Kufi'; font-weight: 800; font-display: swap; src: url(/fonts/kufi-arabic-800.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Kufi'; font-weight: 700; font-display: swap; src: url(/fonts/kufi-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Kufi'; font-weight: 800; font-display: swap; src: url(/fonts/kufi-latin-800.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

/* ============ Tokens ============ */
:root {
  --paper: #f5f7fb;
  --surface: #ffffff;
  --ink: #1c2541;
  --ink-2: #4a5470;
  --ink-3: #6b7490;
  --line: #e1e6f0;
  --line-2: #cfd6e4;

  --lapis: #2d4ba0;       /* main actions */
  --lapis-dark: #223a7e;
  --lapis-soft: #e8edfa;
  --turq: #0f8f8a;        /* done / ok */
  --turq-soft: #e2f4f2;
  --saffron: #b86f0d;     /* needs attention (text-safe shade) */
  --saffron-bright: #e39b2c;
  --saffron-soft: #fdf2e0;
  --rose: #c9476a;        /* errors / delete */
  --rose-soft: #fbe9ee;

  /* stage colours: kindergarten, primary, intermediate, secondary */
  --st-kg: #c9476a;   --st-kg-soft: #fbe9ee;
  --st-pr: #c47a12;   --st-pr-soft: #fdf1df;
  --st-md: #0f8f8a;   --st-md-soft: #e0f3f1;
  --st-hs: #2d4ba0;   --st-hs-soft: #e8edfa;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --font: 'Plex Arabic', Tahoma, 'Segoe UI', system-ui, sans-serif;
  --display: 'Kufi', 'Plex Arabic', Tahoma, sans-serif;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.7;
}
a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; }
bdi { unicode-bidi: isolate; }
[hidden] { display: none !important; }
svg.i { width: 1.25em; height: 1.25em; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }
/* Arabic pages run right to left: "flip" icons are mirrored there, and the back arrow is mirrored in English pages. */
[dir="rtl"] svg.i.flip, [dir="ltr"] svg.i.i-back { transform: scaleX(-1); }
:focus-visible { outline: 3px solid var(--lapis); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Type scale: page title > section > sub-section > body > meta */
h1, h2, h3 { margin: 0; color: var(--ink); }
.page-title { font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1.4; }
.page-sub { margin: .25rem 0 0; color: var(--ink-2); font-size: 1.05rem; }
.section-title { font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1.5; margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; }
.group-title { font-weight: 700; font-size: 1.05rem; color: var(--ink-2); margin: 1.4rem 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.group-title::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--stage, var(--ink-3)); }
.meta { color: var(--ink-3); font-size: .9rem; }
.muted { color: var(--ink-3); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-top: 2rem; padding-bottom: 3rem; }
.page-head { margin-bottom: 2rem; }
.section { margin-bottom: 2.5rem; }
.back { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; margin-bottom: 1rem; color: var(--ink-2); }

/* ============ Header ============ */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .bar { display: flex; align-items: center; gap: 1.5rem; min-height: 72px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--lapis); color: #fff; font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1;
}
.logo { display: block; object-fit: contain; }
.logo-sm { height: 52px; width: auto; max-width: 140px; }
.logo-lg { height: 120px; width: auto; max-width: 100%; margin-bottom: 1.25rem; }
.mark-lg { width: 60px; height: 60px; font-size: 1.8rem; border-radius: 16px; margin-bottom: 1.25rem; }
.credit { text-align: center; font-size: .78rem; color: #9aa2b8; padding: 0 1rem 1.5rem; }
.login .credit { padding-top: 1.25rem; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.1rem; line-height: 1.3; }
.brand-name small { display: block; font-family: var(--font); font-weight: 500; font-size: .8rem; color: var(--ink-3); }
.nav { display: flex; gap: .35rem; flex: 1; }
.nav a {
  display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1rem; border-radius: 999px;
  color: var(--ink-2); font-weight: 600; font-size: 1rem;
}
.nav a:hover { background: var(--paper); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--lapis-soft); color: var(--lapis-dark); }
.who { display: flex; align-items: center; gap: .75rem; font-weight: 600; font-size: .95rem; }
.menu-btn { min-width: 48px; padding: 0; margin-inline-end: -.75rem; }
.menu-btn svg.i { width: 1.6em; height: 1.6em; }

/* ============ Buttons & forms ============ */
.btn, button {
  font: inherit; font-weight: 600; font-size: 1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .5rem 1.15rem; border-radius: var(--r-sm);
  border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink);
  text-decoration: none; line-height: 1.3; white-space: nowrap;
}
.btn:hover, button:hover { border-color: var(--lapis); color: var(--lapis-dark); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary, button.primary { background: var(--lapis); border-color: var(--lapis); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--lapis-dark); border-color: var(--lapis-dark); color: #fff; }
.btn.big, button.big { min-height: 56px; padding: .6rem 1.6rem; font-size: 1.1rem; border-radius: var(--r-md); }
.btn.ghost, button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover, button.ghost:hover { background: var(--paper); border-color: transparent; }
.btn.small, button.small { min-height: 42px; padding: .35rem .85rem; font-size: .95rem; }
button.danger { color: var(--rose); }
button.danger:hover { border-color: var(--rose); color: var(--rose); }

.field { display: block; margin-bottom: 1.2rem; font-weight: 600; font-size: 1rem; }
.field-label { display: block; }
.field .hint { display: block; font-weight: 400; font-size: .88rem; color: var(--ink-3); }
input, select, textarea {
  font: inherit; font-size: 1.05rem; width: 100%; margin-top: .4rem;
  min-height: 52px; padding: .6rem .9rem; border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lapis); box-shadow: 0 0 0 3px var(--lapis-soft); }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; min-height: 0; }
.filepick { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-top: .45rem; padding: .85rem; border: 2px dashed var(--line-2); border-radius: var(--r-md); background: var(--paper); cursor: pointer; font-weight: 500; }
.filepick:hover { border-color: var(--lapis); }
.filepick:focus-within { border-color: var(--lapis); box-shadow: 0 0 0 3px var(--lapis-soft); }
.filepick.chosen { border-style: solid; border-color: var(--turq); background: var(--turq-soft); }
.fp-btn { display: inline-flex; align-items: center; gap: .5rem; min-height: 48px; padding: .5rem 1.1rem; border-radius: var(--r-sm); background: var(--surface); border: 1.5px solid var(--line-2); font-weight: 700; color: var(--lapis-dark); }
.fp-name { color: var(--ink-2); overflow-wrap: anywhere; min-width: 0; flex: 1 1 160px; }
.filepick.chosen .fp-name { color: #0b6b67; font-weight: 600; }
textarea { min-height: 110px; resize: vertical; }
label.check { display: flex; align-items: center; gap: .65rem; font-weight: 600; margin: .25rem 0 1.1rem; cursor: pointer; padding: .7rem .9rem; border-radius: var(--r-sm); background: var(--saffron-soft); color: #7a4a08; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--saffron-bright); }
.error { display: flex; gap: .5rem; align-items: center; color: var(--rose); background: var(--rose-soft); padding: .65rem .9rem; border-radius: var(--r-sm); margin: 0 0 1rem; font-weight: 600; font-size: .98rem; }

/* Password show/hide */
.pw-wrap { position: relative; margin-top: .4rem; }
.pw-wrap input { display: block; width: 100%; margin-top: 0; padding-inline-end: 3.4rem; }
.pw-wrap .pw-eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); z-index: 1; }
.pw-wrap .pw-eye:hover { color: var(--lapis); background: var(--paper); border: 0; }
.pw-wrap input::-ms-reveal, .pw-wrap input::-ms-clear { display: none; } /* Edge's own eye */

/* ============ Status chips ============ */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .75rem; border-radius: 999px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.chip svg.i { width: 1.05em; height: 1.05em; }
.chip.submitted { background: var(--turq-soft); color: #0b6b67; }
.chip.retry_requested { background: var(--saffron-soft); color: var(--saffron); }
.chip.resubmitted { background: var(--lapis-soft); color: var(--lapis-dark); }
.chip.none { background: #eef1f6; color: var(--ink-3); }

/* ============ Class tiles (the signature element) ============ */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.tile {
  --stage: var(--st-hs); --stage-soft: var(--st-hs-soft);
  display: flex; flex-direction: column; gap: .6rem; padding: 1.1rem 1.2rem 1.15rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  color: var(--ink); position: relative; overflow: hidden; min-height: 168px;
}
.tile::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; background: var(--stage); }
.tile:hover { border-color: var(--stage); text-decoration: none; }
.tile-top { display: flex; flex-direction: column; align-items: flex-start; gap: .7rem; }
.numeral {
  min-width: 64px; height: 64px; padding: 0 .5rem; border-radius: 16px; display: grid; place-items: center;
  background: var(--stage-soft); color: var(--stage);
  font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; direction: ltr;
}
.numeral.long { font-size: 1.35rem; }
.numeral sub { font-size: .62em; vertical-align: baseline; margin-inline-start: 2px; }
.tile-name { font-family: var(--display); font-weight: 700; font-size: 1.12rem; line-height: 1.45; }
.tile-teacher { color: var(--ink-3); font-size: .9rem; font-weight: 500; line-height: 1.4; }
.tile-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .9rem; color: var(--ink-2); }
.tile-foot .count { display: inline-flex; align-items: center; gap: .3rem; }
.stage-kg { --stage: var(--st-kg); --stage-soft: var(--st-kg-soft); }
.stage-pr { --stage: var(--st-pr); --stage-soft: var(--st-pr-soft); }
.stage-md { --stage: var(--st-md); --stage-soft: var(--st-md-soft); }
.stage-hs { --stage: var(--st-hs); --stage-soft: var(--st-hs-soft); }

/* ============ Panels, notices, lists ============ */
.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 1.5rem; }
.notice { display: flex; gap: 1rem; align-items: flex-start; background: var(--saffron-soft); border: 1.5px solid #f3d6a6; border-radius: var(--r-lg); padding: 1.25rem 1.4rem; margin-bottom: 2rem; }
.notice > svg.i { width: 30px; height: 30px; color: var(--saffron); margin-top: .2rem; }
.notice h2 { font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: #7a4a08; margin-bottom: .4rem; }
.notice-body { flex: 1; min-width: 0; }
.notice-item { display: block; padding: .7rem 0; border-top: 1px solid #f0d9b2; color: var(--ink); }
.notice-item:first-of-type { border-top: 0; }
.notice-item:hover { text-decoration: none; }
.notice-item strong { font-size: 1.05rem; }
.notice-item:hover strong { text-decoration: underline; }
.notice-item .quote { display: block; margin-top: .2rem; color: #7a4a08; }

.stats { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.stat { display: inline-flex; align-items: center; gap: .6rem; padding: .55rem 1rem; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 600; color: var(--ink-2); }
.stat b { font-family: var(--display); font-size: 1.2rem; color: var(--ink); }
.stat.warn b { color: var(--saffron); }
.stat.info b { color: var(--lapis); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li + li { border-top: 1px solid var(--line); }
.feed a { display: flex; align-items: center; gap: 1rem; padding: .9rem .25rem; color: var(--ink); }
.feed a:hover { text-decoration: none; background: var(--paper); }
.feed .grow { flex: 1; min-width: 0; }
.feed strong { display: block; overflow-wrap: anywhere; }

.empty { text-align: center; color: var(--ink-2); padding: 2.5rem 1rem; background: var(--surface); border: 2px dashed var(--line-2); border-radius: var(--r-lg); }
.empty svg.i { width: 40px; height: 40px; color: var(--ink-3); display: block; margin: 0 auto .6rem; }
.empty p { margin: 0 0 1rem; font-size: 1.05rem; }

/* ============ Class page ============ */
.class-head { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.75rem; }
.class-head .numeral { min-width: 84px; height: 84px; font-size: 2.6rem; border-radius: 20px; }
.class-head .numeral.long { font-size: 1.75rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.tabs a {
  display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.15rem; min-height: 50px;
  border-radius: var(--r-md); background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2); font-weight: 600;
}
.tabs a:hover { border-color: var(--lapis); text-decoration: none; color: var(--ink); }
.tabs a.active { background: var(--lapis); border-color: var(--lapis); color: #fff; }
.tabs .n { min-width: 26px; height: 26px; padding: 0 .4rem; border-radius: 999px; display: inline-grid; place-items: center; font-size: .82rem; background: var(--paper); color: var(--ink-2); }
.tabs a.active .n { background: rgba(255,255,255,.22); color: #fff; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.toolbar .spacer { flex: 1; }
.tpl-links { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .95rem; color: var(--ink-3); }

.doc { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.25rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem 1.25rem; margin-bottom: .85rem; }
.ftype { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; letter-spacing: .02em; direction: ltr; flex-shrink: 0; }
.ftype.pdf { background: #fdecec; color: #c23b3b; }
.ftype.doc { background: #e7effd; color: #2b5fc1; }
.ftype.xls { background: #e3f4ea; color: #1d7a45; }
.ftype.ppt { background: #fdeee3; color: #c25a1d; }
.ftype.file { background: #eef1f6; color: var(--ink-3); }
.ftype.img { background: #f1e9fb; color: #7a3fc2; font-size: .75rem; }
.ftype.vid { background: #e3f3f5; color: #137a86; font-size: .75rem; }
.doc-main { flex: 1 1 260px; min-width: 0; }
.doc-title { font-weight: 700; font-size: 1.1rem; line-height: 1.5; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.doc-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 .4rem; border-radius: 999px; background: var(--saffron-bright); color: #fff; font-size: .8rem; }

/* ============ Dialog ============ */
dialog {
  border: 0; padding: 0; border-radius: var(--r-lg); width: min(680px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem); color: var(--ink); background: var(--surface);
  box-shadow: 0 24px 60px rgba(28, 37, 65, .28);
}
dialog::backdrop { background: rgba(28, 37, 65, .45); }
.dlg-head { display: flex; align-items: flex-start; gap: 1rem; padding: 1.35rem 1.5rem 1rem; border-bottom: 1px solid var(--line); }
.dlg-head .t { flex: 1; min-width: 0; }
.dlg-head h2 { font-family: var(--display); font-weight: 700; font-size: 1.3rem; line-height: 1.5; overflow-wrap: anywhere; }
.dlg-head .meta { margin-top: .15rem; }
.dlg-body { padding: 1.25rem 1.5rem 1.6rem; overflow-y: auto; max-height: calc(100vh - 9rem); }
.dlg-body h3 { font-weight: 700; font-size: 1.05rem; color: var(--ink-2); margin: 1.5rem 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.dlg-body h3:first-child { margin-top: 0; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .5rem; }
.icon-btn { min-height: 44px; min-width: 44px; padding: 0 .8rem; }

.version { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); }
.version:first-of-type { border-top: 0; padding-top: 0; }
.version .grow { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.version .latest { color: var(--turq); font-size: .85rem; font-weight: 700; margin-inline-start: .4rem; }

.comment { padding: .85rem 1rem; border-radius: var(--r-md); background: var(--paper); margin-bottom: .65rem; border-inline-start: 4px solid var(--line-2); }
.comment.coordinator { background: var(--lapis-soft); border-color: var(--lapis); }
.comment.retry { background: var(--saffron-soft); border-color: var(--saffron-bright); }
.comment .by { font-size: .88rem; color: var(--ink-3); margin-bottom: .25rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.comment .by strong { color: var(--ink); }
.comment p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ============ Login ============ */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.login-card { position: relative; width: 100%; max-width: 440px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 2.25rem 2rem 2rem; }
.login-card .mark { width: 60px; height: 60px; font-size: 1.8rem; border-radius: 16px; margin-bottom: 1.25rem; }
.login-card .page-title { font-size: 1.6rem; }
.login-card .page-sub { margin-bottom: 1.75rem; }
.login-card button { width: 100%; }
.login-card .lang-switch { position: absolute; top: .75rem; inset-inline-end: .75rem; width: auto; }

/* ============ Misc ============ */
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.tpl-row:first-child { border-top: 0; padding-top: 0; }
.tpl-row .grow { flex: 1 1 220px; min-width: 0; }
.profile { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--lapis-soft); color: var(--lapis); display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 1.4rem; }
.narrow { max-width: 560px; }
.profile-name { font-size: 1.15rem; }
.feed .numeral { min-width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }
.feed .numeral.long { font-size: 1rem; }

#toast {
  position: fixed; inset-inline: 0; bottom: 1.5rem; margin-inline: auto; width: fit-content; max-width: calc(100vw - 2rem);
  display: flex; align-items: center; gap: .6rem; background: var(--ink); color: #fff; padding: .85rem 1.3rem;
  border-radius: var(--r-md); z-index: 1000; font-weight: 600; box-shadow: 0 10px 30px rgba(28,37,65,.3);
}
#toast.err { background: var(--rose); }

/* ============ Title suggestions ============ */
.field > label { display: block; }
.suggest { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.chip-btn { min-height: 40px; padding: .3rem .9rem; border-radius: 999px; font-size: .95rem; font-weight: 500; background: var(--lapis-soft); border-color: transparent; color: var(--lapis-dark); }
.chip-btn:hover { border-color: var(--lapis); background: var(--lapis-soft); }
.note { background: var(--lapis-soft); color: var(--lapis-dark); padding: .7rem .9rem; border-radius: var(--r-sm); margin: 0 0 1rem; font-size: .95rem; }
details.rename { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details.rename summary { cursor: pointer; font-weight: 700; color: var(--ink-2); display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; }
details.rename[open] summary { margin-bottom: .75rem; }

/* ============ In-site viewer ============ */
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1rem; }
.viewer-title { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.viewer-title strong { font-family: var(--display); font-size: 1.25rem; line-height: 1.5; overflow-wrap: anywhere; }
.viewer-body { background: #e9edf4; border-radius: var(--r-lg); padding: 1rem; min-height: 60vh; }
.viewer-msg { display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 50vh; color: var(--ink-2); font-weight: 600; }
.pdf-pages { direction: ltr; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.pdf-page { width: 100%; max-width: 1000px; background: #fff; box-shadow: 0 2px 10px rgba(28,37,65,.12); border-radius: 4px; overflow: hidden; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.media-wrap { display: flex; justify-content: center; align-items: center; min-height: 50vh; }
.media { display: block; max-width: 100%; max-height: calc(100vh - 240px); border-radius: var(--r-md); background: #000; }
img.media { background: #fff; box-shadow: 0 2px 10px rgba(20, 30, 60, .12); }
.office-frame { display: block; width: 100%; height: calc(100vh - 230px); min-height: 480px; border: 0; border-radius: var(--r-md); background: #fff; }
.viewer-help { text-align: center; color: var(--ink-3); font-size: .9rem; margin: .75rem 0 0; }

/* ============ Subjects: colours, cards and the side menu ============ */
.subj-arabic { --sub: var(--lapis); --sub-soft: var(--lapis-soft); }
.subj-math { --sub: #c47a12; --sub-soft: #fdf1df; }
.subj-science { --sub: #0f8f8a; --sub-soft: #e0f3f1; }
.subj-biology { --sub: #2f8a3e; --sub-soft: #e5f4e7; }
.subj-physics { --sub: #7a3fc2; --sub-soft: #f1e9fb; }
.subj-english { --sub: #0b6fa8; --sub-soft: #e1f0f9; }
.subj-chemistry { --sub: #c8442c; --sub-soft: #fcebe7; }
.subject-icon { display: grid; place-items: center; border-radius: 16px; background: var(--sub-soft); color: var(--sub); flex-shrink: 0; }
.subject-icon .glyph { font-family: var(--display); font-weight: 800; line-height: 1; }
.lang-inline { margin-top: .75rem; }

.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.subject-card {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .35rem;
  min-height: 210px; padding: 1.35rem; white-space: normal; text-align: start;
  border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--surface); position: relative; overflow: hidden;
}
.subject-card::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 6px; background: var(--sub); }
.subject-card:hover { border-color: var(--sub); color: var(--ink); }
.subject-card.on { border-color: var(--sub); box-shadow: 0 0 0 3px var(--sub-soft); }
.subject-card .subject-icon { width: 64px; height: 64px; margin-bottom: .5rem; }
.subject-card .subject-icon svg.i { width: 34px; height: 34px; }
.subject-card .glyph { font-size: 2.1rem; }
.subject-name { font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1.4; color: var(--ink); }
.subject-alt { color: var(--ink-3); font-weight: 500; font-size: .95rem; margin-top: -.25rem; }
.subject-stats { margin-top: auto; padding-top: .75rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .9rem; font-weight: 500; color: var(--ink-2); }
.subject-stats .count { display: inline-flex; align-items: center; gap: .3rem; }

dialog.drawer {
  margin: 0; margin-inline-end: auto; height: 100%; max-height: 100%; width: min(340px, 88vw);
  border-radius: 0; padding: 1rem 1rem 1.5rem; overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; gap: .75rem; padding: .25rem .25rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-title { font-size: .85rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin: 0 .25rem .5rem; }
.drawer-subjects { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .35rem; }
.drawer-subj { width: 100%; justify-content: flex-start; gap: .85rem; min-height: 60px; padding: .45rem .6rem; border-color: transparent; background: transparent; text-align: start; white-space: normal; }
.drawer-subj:hover { background: var(--paper); border-color: transparent; color: var(--ink); }
.drawer-subj.on { background: var(--sub-soft); color: var(--ink); }
.drawer-subj .subject-icon { width: 42px; height: 42px; border-radius: 12px; }
.drawer-subj.on .subject-icon { background: var(--sub); color: #fff; }
.drawer-subj .glyph { font-size: 1.35rem; }
.drawer-subj .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.drawer-subj small { color: var(--ink-3); font-weight: 500; font-size: .82rem; }
.drawer-link { display: flex; align-items: center; justify-content: flex-start; gap: .7rem; width: 100%; min-height: 50px; padding: .4rem .7rem; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--ink-2); font-weight: 600; }
.drawer-link:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.drawer-nav { display: grid; gap: .15rem; }
.drawer .divider { margin: 1rem 0; }

/* ============ Notifications (the bell) ============ */
.bell-wrap { position: relative; }
.bell { position: relative; min-width: 46px; min-height: 46px; padding: 0 .55rem; color: var(--ink-2); }
.bell svg.i { width: 1.45em; height: 1.45em; }
.bell[aria-expanded="true"] { background: var(--paper); }
.bell-count {
  position: absolute; top: 5px; inset-inline-end: 3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--rose); color: #fff; font-size: .72rem; font-weight: 700; line-height: 19px; text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 30; width: min(380px, calc(100vw - 1.5rem)); max-height: min(70vh, 560px);
  overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 18px 50px rgba(28, 37, 65, .22);
  font-weight: 400;
}
.bell-head { padding: .8rem 1rem .6rem; font-weight: 700; font-size: 1rem; color: var(--ink); }
.bell-empty { padding: 1.4rem 1rem 1.6rem; text-align: center; color: var(--ink-3); font-size: .92rem; border-top: 1px solid var(--line); }
.note-row {
  display: flex; align-items: flex-start; justify-content: flex-start; gap: .75rem; width: 100%; min-height: 0; padding: .75rem 1rem;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; text-align: start; white-space: normal; font-weight: 400;
}
.note-row:hover { background: var(--paper); color: var(--ink); }
.note-row.unread { background: #f6f8fe; }
.note-row.unread:hover { background: var(--lapis-soft); }
.note-ic { position: relative; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--paper); color: var(--ink-3); }
.note-ic svg.i { width: 1.05em; height: 1.05em; }
.kind-retry .note-ic { background: var(--saffron-soft); color: var(--saffron); }
.kind-upload .note-ic, .kind-version .note-ic { background: var(--lapis-soft); color: var(--lapis); }
.kind-resubmit .note-ic { background: var(--turq-soft); color: var(--turq); }
.note-row.unread .note-ic::after { content: ''; position: absolute; top: -3px; inset-inline-end: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 2px var(--surface); }
.note-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; line-height: 1.45; }
.note-text { color: var(--ink); font-size: .94rem; overflow-wrap: anywhere; }
.note-row.unread .note-text { font-weight: 700; }
.note-quote { color: var(--ink-2); font-size: .86rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note-main .meta { font-size: .8rem; }
.push-row { display: flex; align-items: center; gap: .65rem; padding: .7rem 1rem; border-top: 1px solid var(--line); background: var(--paper); font-size: .86rem; color: var(--ink-2); line-height: 1.45; }
.push-row .grow { flex: 1; min-width: 0; }
.push-row svg.i { color: var(--ink-3); }
.push-row.push-on svg.i { color: var(--turq); }
.push-row button { min-height: 36px; padding: .2rem .85rem; font-size: .86rem; }

/* ============ Small screens ============ */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .top .bar { gap: .75rem; padding-block: .6rem; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .nav a { padding: .5rem .8rem; }
  .who .name { display: none; }
  .page-title { font-size: 1.6rem; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
  .tile { min-height: 150px; padding: 1rem; }
  .numeral { min-width: 54px; height: 54px; font-size: 1.7rem; }
  .class-head .numeral { min-width: 68px; height: 68px; font-size: 2.1rem; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .tabs a { justify-content: center; white-space: nowrap; padding: .55rem .5rem; font-size: .92rem; gap: .4rem; }
  .tabs a svg.i { display: none; }
  .tabs a:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .doc-actions { width: 100%; }
  .doc-actions .btn, .doc-actions button { flex: 1; }
  .panel { padding: 1.15rem; }
  .viewer-body { padding: .5rem; margin-inline: -.75rem; border-radius: 0; }
  .office-frame { height: calc(100vh - 210px); min-height: 420px; border-radius: 0; }
  .viewer-bar .btn.ghost { padding-inline: .6rem; }
  .bell-wrap { position: static; }
  .bell-panel { position: fixed; top: 4.25rem; inset-inline: .75rem; width: auto; max-height: calc(100vh - 6rem); }
}
