:root {
  --bg: #f4f5f9; --card: #fff; --text: #1d2233; --muted: #6b7185; --line: #e4e6ee;
  --accent: #4a6cf7; --star: #f5b400; --star-off: #d9dce5;
  --ok-bg: #e5f7ec; --ok: #18794e; --warn-bg: #fff4dc; --warn: #8a5a00; --bad: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161d; --card: #1f2230; --text: #eceef5; --muted: #9aa0b4; --line: #2e3243;
    --star-off: #3d4256; --ok-bg: #173826; --ok: #6fdc9f; --warn-bg: #3a2f12; --warn: #f3c86a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Cairo", "Noto Sans Arabic", Tahoma, sans-serif; }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 6px; color: var(--muted); }
.muted { color: var(--muted); font-size: .9rem; }
.error { background: #fde8e6; color: var(--bad); padding: 8px 12px; border-radius: 10px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; text-decoration: none; }
.top nav { display: flex; gap: 4px; align-items: center; }
.top nav a, .link { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted);
  background: none; border: 0; font: inherit; cursor: pointer; }
.top nav a.on { background: var(--accent); color: #fff; }
.top form { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.kid { display: block; text-decoration: none; border-top: 5px solid var(--kid); margin: 0; }
.kid-head, .page-head, .report-head { display: flex; gap: 12px; align-items: center; }
.kid h2 { margin: 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--kid, var(--accent)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; flex: none; }
.avatar.big { width: 56px; height: 56px; font-size: 1.6rem; }
.page-head h1, .report-head h1 { margin: 0; }
.kid-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); }
.kid-foot span:first-child { flex: 1 1 100%; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 14px 0; }
.stats div { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-size: 1.35rem; font-weight: 700; }

.stars { white-space: nowrap; letter-spacing: 1px; direction: ltr; display: inline-block; }
.stars .full { color: var(--star); }
.stars .empty { color: var(--star-off); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--bg); white-space: nowrap; }
.pill.open { background: #e6ecff; color: #2944b8; }
.pill.done { background: var(--warn-bg); color: var(--warn); }
.pill.given, .pill.new { background: var(--ok-bg); color: var(--ok); }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 18px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions form { margin: 0; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.list { list-style: none; padding: 0 16px; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: left; }
ol.wrong { padding-inline-start: 34px; }
ol.wrong li { display: list-item; }
ol.wrong li > div:first-child { display: inline; }
ol.wrong .end { float: left; }
.answer { color: var(--ok); font-size: .9rem; }

.subject summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.subject .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--subj); }
.lessons { list-style: none; padding: 0; margin: 0; }
.lessons li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed var(--line); color: var(--muted); }
.lessons li.played { color: var(--text); }
.lessons .end { flex-direction: row; align-items: center; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }

.login { max-width: 380px; margin: 12vh auto; }
label, .label { display: block; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
input[type=checkbox] { width: auto; }
form .btn { margin-top: 16px; }
.actions form .btn { margin-top: 0; }
fieldset.unit { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; padding: 6px 12px; }
fieldset.unit legend label { margin: 0; }
label.check { font-weight: 400; margin: 6px 0; display: flex; gap: 8px; align-items: center; }

.report { border-top: 6px solid var(--kid); }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 8px; padding: 3px 0; }
.bar { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--kid); border-radius: 6px; }
.num { text-align: left; font-weight: 600; }
