/* نقطتي: light grey ground, white cards with wide radii, one blue for actions, Alexandria throughout. */
:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --ink: #1D1D1F;
  --muted: #6E6E73;
  --line: #E8E8ED;
  --line2: #D2D2D7;
  --blue: #0071E3;
  --link: #0066CC;
  --red: #D70015;
  --green: #248A3D;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.6 "Alexandria", Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
h1 { font-weight: 700; font-size: clamp(32px, 6vw, 44px); line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-weight: 700; font-size: 21px; line-height: 1.3; }
small { display: block; color: var(--muted); font-size: 14px; }
a { color: var(--link); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sub { color: var(--muted); font-size: 19px; margin-top: 8px; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.wrap { max-width: 1024px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 820px; margin: 0 auto; }
.nav { background: rgba(251, 251, 253, 0.85); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line2); position: sticky; top: 0; z-index: 5; }
.nav .wrap { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 700; font-size: 20px; }
main.wrap { padding-top: 40px; padding-bottom: 72px; }
.hero { margin: 16px 0 28px; }
.row-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.grow { flex: 999 1 540px; min-width: 0; }
.side { flex: 1 1 300px; min-width: 0; }

.card { background: var(--card); border-radius: 18px; }
.pad { padding: 28px; margin-bottom: 20px; }
@media (max-width: 600px) { .pad { padding: 20px; } }

/* Buttons */
.btn, .pill, .ghost { font: inherit; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 980px; text-align: center; }
.btn { min-height: 48px; padding: 0 26px; background: var(--blue); color: #fff; font-size: 17px; }
.btn:hover { background: #0077ED; }
.btn:disabled { background: #B9D7F7; cursor: default; }
.btn.wide { width: 100%; }
.pill { min-height: 36px; padding: 0 16px; background: var(--line); color: var(--ink); font-size: 14px; }
.pill:hover { background: #DCDCE1; }
.ghost { min-height: 48px; padding: 0 24px; background: none; color: var(--link); border: 1.5px solid var(--blue); font-size: 17px; }
.link { font: inherit; background: none; border: 0; color: var(--link); cursor: pointer; padding: 6px 0; }
button:focus-visible, label:focus-within, a:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 2px; }

/* Fields */
input, textarea { font: inherit; color: var(--ink); }
.field { display: block; margin: 18px 0; }
.field span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--line2); border-radius: 12px; background: #fff; }
.field input:focus, textarea:focus { outline: none; border-color: var(--blue); }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; padding: 36px 28px; }
.login h1 { font-size: 34px; text-align: center; }
.login .sub { text-align: center; font-size: 17px; }
.err { color: var(--red); font-size: 15px; margin-top: 10px; }

/* Lists */
.list { padding: 4px 28px; }
@media (max-width: 600px) { .list { padding: 4px 18px; } }
.item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item b { font-weight: 600; font-size: 19px; }
.empty { padding: 32px 0; color: var(--muted); text-align: center; }
.ok { color: var(--green); }
.side { padding: 24px 28px; }
.groups { list-style: none; margin: 12px 0 0; padding: 0; }
.groups li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.groups b { font-weight: 600; font-size: 15px; }
.side label.link { display: flex; justify-content: center; min-height: 44px; align-items: center; margin-top: 8px; }

/* New exam */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 18px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--blue); }
.choice input { width: 20px; height: 20px; accent-color: var(--blue); flex: none; }
.choice b { display: block; font-weight: 600; font-size: 15px; }
.alert { margin-top: 16px; padding: 14px 18px; background: #FFF2F2; border-radius: 14px; color: #A50011; font-size: 15px; }
.drop { display: flex; align-items: center; justify-content: center; min-height: 64px; margin-top: 18px; padding: 12px 16px; background: var(--bg); border-radius: 12px; color: var(--link); cursor: pointer; text-align: center; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; margin-top: 14px; }
.page { display: flex; flex-direction: column; gap: 8px; padding: 0; background: none; border: 0; font: inherit; color: var(--link); cursor: pointer; font-size: 13px; font-weight: 600; }
.page canvas { width: 100%; height: auto; border: 2px solid var(--blue); border-radius: 8px; background: #fff; }
.page.ans { color: var(--red); }
.page.ans canvas { border-color: var(--red); opacity: 0.5; }

/* Correction */
.seg { display: flex; padding: 2px; margin: 0 0 16px; background: #E3E3E8; border-radius: 10px; overflow-x: auto; }
.seg button { flex: 1; min-height: 36px; padding: 0 14px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.srow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .who { flex: 1; min-width: 150px; }
.srow .who b { font-weight: 500; font-size: 16px; }
.srow .who small.ok { color: var(--green); }
.srow .who small.bad { color: var(--red); }
.cam { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--blue); color: #fff; cursor: pointer; flex: none; }
.cam.has { background: #E8F2FD; color: var(--link); }
.grade { display: flex; align-items: baseline; gap: 2px; min-height: 44px; padding: 0 10px; background: var(--bg); border-radius: 10px; flex: none; }
.grade input { width: 52px; border: 0; background: none; font-weight: 700; font-size: 19px; text-align: center; padding: 8px 0; }
.grade input:focus { outline: none; }
.grade.bad { background: #FFF2F2; }
.grade span:last-child { font-size: 13px; color: var(--muted); }
.notes { flex-basis: 100%; }
.notes summary { cursor: pointer; color: var(--link); font-size: 14px; }
.notes textarea { width: 100%; min-height: 110px; margin-top: 8px; padding: 12px; border: 1.5px solid var(--line2); border-radius: 12px; font-size: 15px; line-height: 1.7; resize: vertical; }
.notes .row { margin-top: 6px; gap: 8px 16px; }
.img { display: inline-flex; align-items: center; gap: 2px; }
.x { font: inherit; background: none; border: 0; color: var(--red); cursor: pointer; padding: 2px 6px; font-size: 18px; line-height: 1; }
.danger { font: inherit; min-height: 44px; padding: 0 22px; border-radius: 980px; border: 1.5px solid var(--red); background: none; color: var(--red); cursor: pointer; margin-top: 10px; }
.danger:hover { background: #FFF2F2; }
.drop .fname { pointer-events: none; }

/* Student */
.st { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #fff; }
.st-top { padding: 56px 24px 40px; text-align: center; }
.st-brand { font-weight: 700; font-size: 17px; color: var(--muted); }
.pinrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; direction: ltr; margin: 14px 0 12px; position: relative; }
.pinrow div { height: 68px; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 2px solid transparent; border-radius: 14px; font-weight: 700; font-size: 30px; }
.pinrow div.cur { border-color: var(--blue); }
.pinrow input { position: absolute; inset: 0; opacity: 0; font-size: 16px; }
.big { font-weight: 700; font-size: 96px; line-height: 1; letter-spacing: -0.02em; margin-top: 24px; }
.st-body { background: var(--bg); padding: 4px 16px 40px; }
.st-card { background: #fff; border-radius: 18px; padding: 22px; margin-top: 16px; }
.st-card img { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--line); margin-top: 12px; }
.pre { white-space: pre-wrap; }
details.key summary { list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 44px; cursor: pointer; }
details.key summary::-webkit-details-marker { display: none; }
details.key summary span { color: var(--link); font-size: 15px; font-weight: 400; }

/* Student extras */
.appr { color: var(--ink); font-weight: 600; }
.st-top .ghost { font-size: 16px; min-height: 44px; }
.st-card .ok, .st-card.ok { color: var(--green); }
.st-card .bad { color: var(--red); }
.pic { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; cursor: zoom-in; }
.hist { list-style: none; margin: 10px 0 0; padding: 0; }
.hist li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.hist li.cur { font-weight: 600; }
.hist .up { color: var(--green); } .hist .down { color: var(--red); } .hist .same { color: var(--muted); }
#rv textarea { width: 100%; min-height: 100px; margin-top: 10px; padding: 12px; border: 1.5px solid var(--line2); border-radius: 12px; font-size: 16px; line-height: 1.7; resize: vertical; }
dialog#viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; }
dialog#viewer::backdrop { background: #000; }
.vbar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; padding: 10px; background: rgba(0, 0, 0, 0.6); }
.vbox { overflow: auto; height: calc(100dvh - 56px); -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.vbox img { display: block; width: 100%; height: auto; }
.vbox img.z { width: 250%; max-width: none; }

/* Teacher: review requests */
.review { flex-basis: 100%; padding: 12px 14px; background: #FFF8E6; border-radius: 12px; font-size: 15px; }
.review.done { background: var(--bg); }
.review textarea { width: 100%; min-height: 60px; margin-top: 8px; padding: 10px; border: 1.5px solid var(--line2); border-radius: 10px; font-size: 15px; }
.badge { display: inline-block; padding: 0 10px; border-radius: 980px; background: #FFE7A8; color: #6B4A00; font-size: 13px; }
