:root {
  --bg: #f4f5f7; --bg2: #eceef2; --card: #ffffff; --ink: #1f2937; --muted: #6b7280;
  --accent: #2563eb; --on-accent: #ffffff; --good: #16a34a; --mid: #d97706; --low: #dc2626; --line: rgba(0,0,0,.08);
}
[data-scheme="dark"] { --line: rgba(255,255,255,.1); }
/* خارج تلكرام: ألوان الوضع الليلي من الجهاز (داخل تلكرام تأتي من ألوانه) */
@media (prefers-color-scheme: dark) {
  html:not([data-tg]) { --bg: #0f172a; --bg2: #1e293b; --card: #111827; --ink: #e5e7eb; --muted: #94a3b8; --accent: #3b82f6; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", sans-serif; }
main { padding: 14px 14px 92px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 19px; margin: 6px 2px 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 6px 0; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.card { background: var(--card); border-radius: 14px; padding: 14px; margin: 0 0 10px; border: 1px solid var(--line); }
.card.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details.card summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
details.card summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.hero { background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; border-radius: 18px; padding: 18px; margin-bottom: 10px; }
.hero .hello { opacity: .85; }
.hero .lvl { font-size: 22px; font-weight: 700; }
.hero .pts { font-size: 34px; font-weight: 800; line-height: 1.2; }
.hero .muted { color: rgba(255,255,255,.85); }
.hero .bar { background: rgba(255,255,255,.25); }
.hero .bar i { background: #fff; }
.grid3, .grid2 { display: grid; gap: 8px; margin-bottom: 10px; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.alert b { color: var(--low); }
.count { text-align: center; font-size: 15px; }
.count b { font-size: 24px; color: var(--accent); }
.bar { height: 9px; background: var(--bg2); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.good i { background: var(--good); } .bar.mid i { background: var(--mid); } .bar.low i { background: var(--low); }
.meter { margin: 8px 0 12px; }
.ml { display: flex; justify-content: space-between; gap: 8px; }
.btn { display: inline-block; border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; cursor: pointer; margin: 4px 0; }
.btn.wide { width: 100%; margin-bottom: 10px; }
.btn.ghost, .ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--low); }
.btn.ghost.danger { background: transparent; color: var(--low); border-color: var(--low); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .tag { background: var(--bg2); border-radius: 20px; padding: 3px 10px; font-size: 13px; }
.tag { font-size: 12px; }
.due { color: var(--low); font-weight: 600; }
pre.q { white-space: pre-wrap; font: inherit; background: var(--bg2); padding: 10px; border-radius: 10px; margin: 6px 0; }
.fb { color: var(--muted); font-size: 14px; }
.boxes { display: flex; gap: 4px; align-items: center; margin-top: 8px; }
.boxes i { width: 18px; height: 8px; border-radius: 4px; background: var(--bg2); }
.boxes i.on { background: var(--good); }
.score { font-weight: 700; margin-inline-start: auto; }
.score.ok { color: var(--good); } .score.bad { color: var(--low); }
.qrow { border-top: 1px solid var(--line); padding: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.qrow p { width: 100%; margin: 0; color: var(--muted); font-size: 14px; }
.rank { display: flex; justify-content: space-between; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.rank:last-child { border: 0; }
.rank.me { background: var(--bg2); border-radius: 8px; }
.search, input[type=text], input[type=number], input[type=date], input[type=time], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; margin: 4px 0 10px; }
textarea { min-height: 70px; }
label { display: block; font-size: 13px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; padding: 8px 2px; }
.toggle input { width: 20px; height: 20px; }
.md h2, .md h3, .md h4 { margin: 14px 0 6px; } .md ul { padding-inline-start: 20px; margin: 4px 0; }
.md code { background: var(--bg2); padding: 0 4px; border-radius: 4px; }
.empty .big { font-size: 42px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 5; overflow-x: auto; }
.tabs button { flex: 1; min-width: 46px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px; padding: 4px 2px; cursor: pointer; }
.tabs button span { display: block; font-size: 19px; }
.tabs button.on { color: var(--accent); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: start; }
tr.click { cursor: pointer; }
.pill { font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--bg2); }
.pill.warn { background: #fde68a; color: #7c2d12; } .pill.ap { background: #ddd6fe; color: #3b0764; }
#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 9; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* الامتحان */
.examcall { display: flex; justify-content: space-between; align-items: center; background: #fef3c7; border-color: #f59e0b; cursor: pointer; }
.exbar { position: sticky; top: 0; z-index: 4; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
.exbar #timer { font-size: 18px; font-variant-numeric: tabular-nums; }
.exbar span:nth-child(2) { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.qchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.qchips button { min-width: 36px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; }
.qchips button.ok { background: #dcfce7; border-color: var(--good); color: #14532d; }
.qchips button.cur { outline: 2px solid var(--accent); }
.exq textarea { min-height: 110px; }
.qt { font-weight: 600; }
.exnav { display: flex; justify-content: space-between; gap: 10px; }
.exnav .btn { flex: 1; }
.imgs { margin: 6px 0; }
.imgrow { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; }
.imgrow.warn { color: var(--low); }
label.btn { display: inline-block; text-align: center; }
#wm { position: fixed; inset: 0; pointer-events: none; z-index: 8; display: flex; flex-wrap: wrap; align-content: space-around;
  justify-content: space-around; overflow: hidden; opacity: .07; }
#wm span { transform: rotate(-28deg); font-size: 16px; font-weight: 700; color: var(--ink); padding: 26px 18px; white-space: nowrap; }
.ok { color: var(--good); }
.flash { min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  font-size: 19px; cursor: pointer; background: linear-gradient(160deg, var(--card), var(--bg2)); }
.flash.back { background: #ecfdf5; color: #064e3b; }

/* منصة الويب */
#topbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--card); border-bottom: 1px solid var(--line); }
#topbar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar button { position: relative; border: 0; background: var(--bg2); border-radius: 10px; font-size: 18px; padding: 4px 9px; cursor: pointer; }
#nbadge, #dmbadge { position: absolute; top: -4px; left: -4px; background: var(--low); color: #fff; border-radius: 9px; font-size: 11px;
  font-style: normal; padding: 0 5px; min-width: 16px; }
.auth { max-width: 420px; margin: 30px auto; }
.auth a { display: block; text-align: center; margin-top: 12px; }
.btn.wide, .wide { width: 100%; }
input[type=password] { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; margin: 4px 0 10px; }
.note.new { border-inline-start: 4px solid var(--accent); }
.rq { border-top: 1px solid var(--line); padding: 8px 0; }
.rq .ok { color: var(--good); } .rq .bad { color: var(--low); }
.total { font-weight: 700; font-size: 17px; border-top: 2px solid var(--line); padding-top: 8px; }
.paper img { width: 100%; border-radius: 10px; margin: 6px 0; border: 1px solid var(--line); }
.msg { padding: 10px 12px; border-radius: 14px; margin: 6px 0; max-width: 92%; }
.msg.me { background: var(--accent); color: var(--on-accent); margin-inline-start: auto; width: fit-content; }
.msg.bot { background: var(--card); border: 1px solid var(--line); }
.ask textarea { min-height: 70px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.grid4 .stat { cursor: pointer; font: inherit; color: var(--ink); }
.grid4 .stat b { font-size: 22px; display: block; }
.ann img { width: 100%; border-radius: 10px; margin: 6px 0; }
.ann.pin { border-inline-start: 4px solid var(--mid); }
.chathead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chathead select { width: auto; display: inline-block; margin: 0; padding: 4px 8px; }
#chatbox, #dmbox, #agbox, #mnbox { height: calc(100vh - 300px); min-height: 260px; overflow-y: auto; padding: 4px 2px; }
.cmsg { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 7px 11px; margin: 5px 0;
  max-width: 85%; width: fit-content; }
.cmsg b { display: block; font-size: 12.5px; color: var(--accent); }
.cmsg i { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.cmsg.me { background: var(--accent); color: var(--on-accent); margin-inline-start: auto; }
.cmsg.me i { color: rgba(255,255,255,.75); }
.cmsg.staffmsg { border-color: var(--mid); background: #fffbeb; }
[data-scheme="dark"] .cmsg.staffmsg { background: #3a2f12; }
.cmsg.del span { text-decoration: line-through; opacity: .6; }
.chatin { display: flex; gap: 6px; align-items: flex-end; }
.chatin textarea { min-height: 42px; margin: 0; flex: 1; }
.tabs button { position: relative; }
#dmbadge { top: 0; left: 8px; }
.row.click { cursor: pointer; }
.pinbar { background: var(--bg2); border-inline-start: 3px solid var(--accent); border-radius: 10px; padding: 6px 10px; margin: 4px 0; font-size: 13.5px; }
.pinbar a { font-size: 12px; }
#subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; max-width: 760px; margin: 0 auto; }
#subtabs:empty { display: none; }
#subtabs button { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 18px;
  padding: 6px 13px; font: inherit; font-size: 13.5px; cursor: pointer; position: relative; }
#subtabs button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
#subtabs i { position: static; display: inline-block; margin-inline-start: 4px; }
.opt { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 5px 0; }
.opt.ok { border-color: #16a34a; background: rgba(22, 163, 74, .08); font-weight: 700; }
