@font-face { font-family: 'Cairo'; font-weight: 400; src: url(fonts/cairo-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Cairo'; font-weight: 700; src: url(fonts/cairo-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Cairo'; font-weight: 900; src: url(fonts/cairo-arabic-900-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: 'Cairo'; font-weight: 400; src: url(fonts/cairo-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Cairo'; font-weight: 700 900; src: url(fonts/cairo-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #f4f1ff; --card: #ffffff; --ink: #1f1640; --muted: #6b6390; --line: #e4def8;
  --brand: #6c3cf0; --brand2: #9b6dff; --ok: #1fb36b; --okbg: #e3f8ec; --bad: #e5484d; --badbg: #fde8e8;
  --gold: #ffb300; --code: #1e1b2e; --codeink: #f1ecff;
  --mono: Consolas, 'Cascadia Mono', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: var(--ink); direction: rtl; font-size: 17px; -webkit-user-select: none; user-select: none; overflow: hidden; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; overflow: auto; }
code, .ltr { direction: ltr; unicode-bidi: isolate; }
code { font-family: var(--mono); background: #efe9ff; color: #5326c9; padding: 1px 7px; border-radius: 6px; font-size: .92em; }
b { color: var(--brand); }

/* ---------- buttons ---------- */
.btn { background: var(--brand); color: #fff; font-weight: 700; padding: 12px 26px; border-radius: 14px; box-shadow: 0 4px 0 #4b22b8; transition: transform .08s; font-size: 18px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4b22b8; }
.btn:disabled { background: #c9c2e3; box-shadow: 0 4px 0 #aaa2c9; cursor: not-allowed; }
.btn.ok { background: var(--ok); box-shadow: 0 4px 0 #128a50; }
.btn.bad { background: var(--bad); box-shadow: 0 4px 0 #b12a2e; }
.btn.ghost { background: #fff; color: var(--brand); box-shadow: 0 3px 0 var(--line); border: 2px solid var(--line); }
.btn.sm { padding: 7px 14px; font-size: 15px; border-radius: 10px; }
.iconbtn { background: transparent; font-size: 22px; padding: 6px 10px; border-radius: 10px; color: var(--muted); }
.iconbtn:hover { background: #ebe5ff; }

/* ---------- login ---------- */
#login { display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #d9ccff 0, transparent 40%), radial-gradient(circle at 90% 90%, #ffd9c7 0, transparent 40%), var(--bg); }
.login-box { width: min(880px, 94vw); text-align: center; padding: 30px 0; }
.logo { font-size: 64px; line-height: 1; }
.app-title { font-size: 44px; font-weight: 900; margin: 6px 0 0; color: var(--brand); }
.app-sub { color: var(--muted); margin: 0 0 4px; font-size: 18px; }
.school-name { color: var(--ink); font-weight: 700; margin-bottom: 22px; }
.students { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 18px 0; }
.stu { background: #fff; border-radius: 18px; padding: 16px 10px; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); cursor: pointer; transition: transform .1s; }
.stu:hover { transform: translateY(-3px); border-color: var(--brand2); }
.avatar { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 6px; color: #fff; font-weight: 900; font-size: 24px; background: linear-gradient(135deg, var(--brand), #ff7a59); }
.stu .n { font-weight: 700; }
.stu .c { color: var(--muted); font-size: 14px; }
.new-stu { background: #fff; border-radius: 20px; padding: 22px; border: 2px dashed var(--brand2); max-width: 560px; margin: 10px auto; }
.new-stu h3 { margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.field { padding: 11px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; outline: none; min-width: 0; }
.field:focus { border-color: var(--brand2); }
.teacher-link { position: fixed; top: 14px; left: 14px; z-index: 6; }

/* ---------- home ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 10px 22px; }
.topbar .avatar { width: 42px; height: 42px; font-size: 18px; margin: 0; }
.topbar .who { line-height: 1.2; }
.topbar .who .c { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.pill { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 4px 14px; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.home-wrap { max-width: 900px; margin: 0 auto; padding: 24px 18px 80px; }
.stage { background: #fff; border-radius: 24px; margin-bottom: 26px; border: 2px solid var(--line); overflow: hidden; position: relative; }
.stage-head { padding: 18px 22px; color: #fff; display: flex; gap: 16px; align-items: center; }
.stage-head .ic { font-size: 44px; background: rgba(255,255,255,.22); border-radius: 18px; width: 70px; height: 70px; display: grid; place-items: center; }
.stage-head h2 { margin: 0; font-size: 24px; }
.stage-head .en { opacity: .9; font-size: 14px; direction: ltr; text-align: right; }
.stage-head p { margin: 4px 0 0; opacity: .95; font-size: 15px; }
.stage-prog { height: 8px; background: rgba(255,255,255,.3); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.stage-prog i { display: block; height: 100%; background: #fff; border-radius: 9px; }
.path { padding: 26px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.node { display: flex; flex-direction: column; align-items: center; width: 220px; cursor: pointer; }
.node .dot { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 32px; background: #fff; border: 4px solid var(--line); box-shadow: 0 6px 0 var(--line); transition: transform .12s; position: relative; }
.node:hover .dot { transform: scale(1.06); }
.node .t { font-weight: 700; margin-top: 8px; text-align: center; line-height: 1.3; }
.node .e { font-size: 12px; color: var(--muted); direction: ltr; }
.node .xp { font-size: 12px; color: var(--gold); font-weight: 700; }
.node.done .dot { background: var(--ok); border-color: #128a50; box-shadow: 0 6px 0 #128a50; color: #fff; }
.node.current .dot { border-color: var(--brand); box-shadow: 0 6px 0 var(--brand), 0 0 0 8px rgba(108,60,240,.15); animation: pulse 1.6s infinite; }
.node.locked { cursor: not-allowed; opacity: .55; }
.node.locked .dot { filter: grayscale(1); }
.node .badge-done { position: absolute; bottom: -4px; left: -4px; background: var(--gold); color: #fff; border-radius: 50%; width: 26px; height: 26px; font-size: 14px; display: grid; place-items: center; border: 2px solid #fff; }
.node:nth-child(4n+2) { transform: translateX(-70px); } .node:nth-child(4n+4) { transform: translateX(70px); }
.stage.locked .path { filter: grayscale(.8); opacity: .6; }
.lock-note { text-align: center; color: var(--muted); padding: 0 0 18px; font-weight: 700; }
.cert-ready { margin: 0 20px 20px; background: #fff8e1; border: 2px solid #ffe082; border-radius: 16px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 var(--brand), 0 0 0 16px rgba(108,60,240,.05); } }

/* ---------- player ---------- */
#player { display: flex; flex-direction: column; background: #fff; overflow: hidden; }
.p-top { display: flex; align-items: center; gap: 16px; padding: 12px 22px; }
.p-prog { flex: 1; height: 16px; background: #eee9fb; border-radius: 99px; overflow: hidden; }
.p-prog i { display: block; height: 100%; background: linear-gradient(90deg, #8a5cff, var(--ok)); border-radius: 99px; transition: width .3s; }
.hearts { font-size: 22px; letter-spacing: 2px; }
.p-title { color: var(--muted); font-weight: 700; font-size: 15px; }
.p-body { flex: 1; overflow: auto; padding: 18px 20px 30px; }
.card { max-width: 760px; margin: 0 auto; animation: slidein .25s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(-24px); } }
.card .img { font-size: 84px; text-align: center; margin: 4px 0 10px; }
.card .txt { font-size: 21px; line-height: 1.9; }
.card .q { font-size: 22px; font-weight: 700; line-height: 1.8; margin-bottom: 16px; }
.note { background: #f3efff; border-inline-start: 5px solid var(--brand2); padding: 12px 16px; border-radius: 12px; margin-top: 16px; font-size: 18px; line-height: 1.8; }
.note::before { content: '💡 '; }
pre.code { background: var(--code); color: var(--codeink); direction: ltr; text-align: left; padding: 16px 18px; border-radius: 14px; font-family: var(--mono); font-size: 18px; line-height: 1.6; margin: 14px 0; position: relative; white-space: pre-wrap; -webkit-user-select: text; user-select: text; overflow: auto; }
pre.code .lang { position: absolute; top: 6px; right: 10px; font-size: 11px; color: #a993ff; font-family: 'Cairo'; letter-spacing: 1px; }
.tk-k { color: #ff8ad8; } .tk-s { color: #9ff07c; } .tk-n { color: #ffcb6b; } .tk-c { color: #8a83a8; font-style: italic; } .tk-t { color: #7ec8ff; } .tk-a { color: #ffcb6b; } .tk-f { color: #82e9ff; }
.run-out { margin-top: -6px; }
.out { background: #0f0d1a; color: #c8ffbf; direction: ltr; text-align: left; font-family: var(--mono); padding: 12px 16px; border-radius: 12px; white-space: pre-wrap; min-height: 44px; font-size: 17px; }
.out .err { color: #ff9a9a; }
.out .errar { color: #ffd27a; direction: rtl; text-align: right; font-family: 'Cairo'; display: block; margin-bottom: 4px; }
.out-label { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
iframe.preview { width: 100%; height: 230px; border: 2px solid var(--line); border-radius: 12px; background: #fff; }

.opts { display: grid; gap: 12px; }
.opt { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 14px 18px; font-size: 19px; text-align: right; box-shadow: 0 4px 0 var(--line); color: var(--ink); }
.opt:hover { border-color: var(--brand2); }
.opt.sel { border-color: var(--brand); background: #f3efff; box-shadow: 0 4px 0 var(--brand2); }
.opt.right { border-color: var(--ok); background: var(--okbg); }
.opt.wrong { border-color: var(--bad); background: var(--badbg); }
.blank { display: inline-block; min-width: 70px; height: 32px; vertical-align: middle; border-bottom: 3px solid #a993ff; background: #2d2944; border-radius: 6px; margin: 0 2px; padding: 0 8px; cursor: pointer; text-align: center; color: #fff; line-height: 32px; }
.blank.filled { background: #4b3a8f; }
.blank input { width: 120px; background: transparent; border: 0; color: #fff; font-family: var(--mono); font-size: 18px; outline: none; text-align: center; }
.tokens { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 20px; direction: ltr; }
.tok { background: #fff; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); border-radius: 12px; padding: 8px 18px; font-family: var(--mono); font-size: 18px; color: var(--ink); }
.tok:hover { border-color: var(--brand2); }
.order-zone { min-height: 60px; border: 2px dashed var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.order-zone.answer { border-color: var(--brand2); background: #faf8ff; }
.oline { background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 9px 14px; font-size: 18px; box-shadow: 0 3px 0 var(--line); text-align: right; color: var(--ink); white-space: pre; }
.oline.code { direction: ltr; text-align: left; font-family: var(--mono); }
.oline .num { display: inline-block; width: 26px; color: var(--brand); font-weight: 900; }
.zone-label { font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* robot */
.robot-wrap { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.grid { display: inline-grid; gap: 4px; background: #d9d1f5; padding: 6px; border-radius: 14px; direction: ltr; }
.cell { width: 62px; height: 62px; background: #fff; border-radius: 8px; display: grid; place-items: center; font-size: 34px; position: relative; }
.cell.wall { background: #8d6e63; }
.cell.trail { background: #ece5ff; }
.robot-side { min-width: 280px; flex: 1; max-width: 420px; }
.prog-bar { min-height: 64px; background: #1e1b2e; border-radius: 14px; padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; direction: ltr; align-items: center; }
.prog-bar .empty { color: #8a83a8; font-size: 14px; direction: rtl; width: 100%; text-align: center; }
.blk { background: #6c3cf0; color: #fff; border-radius: 9px; padding: 4px 9px; font-size: 22px; }
.blk.rep { background: #ff8f00; font-size: 17px; font-weight: 900; }
.blk.active { outline: 3px solid #ffeb3b; }
.palette { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; direction: ltr; justify-content: center; }
.palette button { font-size: 28px; background: #fff; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); border-radius: 12px; width: 62px; height: 56px; }
.palette button.rep { background: #fff3e0; border-color: #ffcc80; font-size: 22px; width: auto; padding: 0 12px; }
.rep-pick { display: flex; gap: 6px; justify-content: center; direction: ltr; margin-bottom: 8px; }
.rep-pick button { background: #ff8f00; color: #fff; border-radius: 10px; width: 44px; height: 40px; font-weight: 900; font-size: 18px; }
.limit { text-align: center; color: var(--muted); font-size: 15px; }

/* code editor */
.editor { width: 100%; min-height: 200px; background: var(--code); color: var(--codeink); font-family: var(--mono); font-size: 18px; line-height: 1.6; padding: 14px 16px; border-radius: 14px; border: 3px solid transparent; direction: ltr; text-align: left; resize: vertical; outline: none; tab-size: 4; white-space: pre; }
.editor:focus { border-color: var(--brand2); }
.ed-bar { display: flex; gap: 10px; align-items: center; margin: 8px 0; }

/* bottom bar & feedback */
.p-bottom { border-top: 2px solid var(--line); padding: 16px 22px; display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 86px; transition: background .2s; }
.p-bottom.ok { background: var(--okbg); border-color: #b6ebcd; }
.p-bottom.bad { background: var(--badbg); border-color: #f6c2c3; }
.fb { flex: 1; max-width: 640px; font-size: 19px; font-weight: 700; line-height: 1.6; }
.fb small { display: block; font-weight: 400; font-size: 16px; color: var(--ink); }
.p-bottom.ok .fb { color: #128a50; } .p-bottom.bad .fb { color: #b12a2e; }

/* ---------- done / modals ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(31,22,64,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 26px; padding: 28px; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; text-align: center; animation: pop .25s ease; }
.modal.wide { width: min(1000px, 100%); text-align: right; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.big-emoji { font-size: 80px; line-height: 1.1; }
.done-title { font-size: 30px; font-weight: 900; margin: 8px 0; }
.code-box { background: linear-gradient(135deg, #2b1a6b, #6c3cf0); color: #fff; border-radius: 18px; padding: 14px; margin: 14px 0; }
.code-box .lbl { font-size: 14px; opacity: .85; }
.code-box .cd { font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: 2px; direction: ltr; -webkit-user-select: text; user-select: text; }
.code-box.gold { background: linear-gradient(135deg, #b26a00, #ffb300); }
.code-box.badge { background: linear-gradient(135deg, #00796b, #26a69a); }
.stats { display: flex; gap: 12px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.confetti { position: fixed; top: -40px; font-size: 26px; z-index: 60; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* achievements */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0 22px; }
.bdg { border: 2px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; background: #fff; }
.bdg .i { font-size: 38px; }
.bdg .t { font-weight: 700; }
.bdg .d { font-size: 13px; color: var(--muted); }
.bdg.off { opacity: .4; filter: grayscale(1); }
.bdg .cd, .codes-table .cd { font-family: var(--mono); direction: ltr; font-weight: 700; color: var(--brand); font-size: 14px; -webkit-user-select: text; user-select: text; }
.codes-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.codes-table th, .codes-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: right; }
.codes-table th { background: #f6f3ff; position: sticky; top: 0; }
h3.sec { margin: 18px 0 6px; }

/* teacher */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { background: transparent; padding: 10px 16px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.on { color: var(--brand); border-color: var(--brand); }
.verify-res { margin-top: 16px; border-radius: 16px; padding: 16px; font-size: 18px; line-height: 1.9; }
.verify-res.ok { background: var(--okbg); border: 2px solid #b6ebcd; }
.verify-res.bad { background: var(--badbg); border: 2px solid #f6c2c3; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
.warn { color: var(--bad); font-weight: 700; }
.muted { color: var(--muted); }

/* ---------- certificate ---------- */
#certView .modal { width: min(1060px, 100%, calc((92vh - 110px) * 1.414 + 36px)); padding: 18px; }
.cert { container-type: inline-size; width: 100%; aspect-ratio: 297 / 210; background: #fff; position: relative; color: #1f1640; overflow: hidden; border-radius: 6px; }
.cert-frame { position: absolute; inset: 2.2%; border: 9px double var(--cc, #6c3cf0); border-radius: 10px; }
.cert-corner { position: absolute; width: 22%; aspect-ratio: 1; border-radius: 50%; background: var(--cc, #6c3cf0); opacity: .12; }
.cert-in { position: absolute; inset: 6% 8%; display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: space-between; }
.cert .school { font-weight: 700; font-size: 1.15cqw; color: #5a527c; }
.cert .ttl { font-size: 3.6cqw; font-weight: 900; color: var(--cc, #6c3cf0); line-height: 1.2; }
.cert .ttl-en { font-size: 1.2cqw; letter-spacing: .4em; color: #8a83a8; direction: ltr; }
.cert .line { font-size: 1.45cqw; line-height: 1.9; }
.cert .stu-name { font-size: 3cqw; font-weight: 900; border-bottom: 3px solid var(--gold); padding: 0 30px; display: inline-block; line-height: 1.5; }
.cert .stage-name { font-weight: 900; color: var(--cc, #6c3cf0); }
.cert .sig-row { display: flex; width: 100%; justify-content: space-between; align-items: flex-end; font-size: 1.1cqw; }
.cert .sig { text-align: center; min-width: 22%; }
.cert .sig .s { border-top: 2px solid #c9c2e3; padding-top: 6px; margin-top: 2.6cqw; font-weight: 700; }
.cert .cert-code { text-align: center; }
.cert .cert-code .cd { font-family: var(--mono); font-size: 1.7cqw; font-weight: 700; direction: ltr; background: #f3efff; padding: 4px 14px; border-radius: 8px; letter-spacing: 1px; color: #2b1a6b; }
.cert .medal { font-size: 4.2cqw; line-height: 1; }
.cert-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

@media print {
  @page { size: A4 landscape; margin: 0; }
  body { background: #fff; overflow: visible; }
  body > *:not(#certView) { display: none !important; }
  #certView { position: static; background: none; padding: 0; display: block; }
  #certView .modal { width: 297mm; height: 210mm; padding: 0; border-radius: 0; max-height: none; animation: none; overflow: hidden; }
  .cert { width: 297mm; height: 210mm; aspect-ratio: auto; border-radius: 0; }
  .cert .school { font-size: 13pt; } .cert .ttl { font-size: 40pt; } .cert .ttl-en { font-size: 13pt; }
  .cert .line { font-size: 16pt; } .cert .stu-name { font-size: 32pt; } .cert .sig-row { font-size: 12pt; }
  .cert .sig .s { margin-top: 28pt; } .cert .cert-code .cd { font-size: 18pt; } .cert .medal { font-size: 44pt; }
  .cert-actions { display: none !important; }
}

/* ---------- v2: أسلوب شرح قصير + تمرين ---------- */
.card.wide { max-width: 900px; }
.card .img.sm { font-size: 54px; margin: 0 0 6px; }
.lead { font-size: 19px; line-height: 1.8; color: #3b3260; margin-bottom: 10px; }
.c-title { text-align: center; font-size: 28px; margin: 4px 0 12px; color: var(--brand); }
.again { background: #fff3e0; color: #b26a00; border: 2px solid #ffcc80; border-radius: 12px; padding: 8px 14px; font-weight: 700; margin-bottom: 14px; text-align: center; }
ul.recap { list-style: none; padding: 0; font-size: 20px; line-height: 2.1; }
.opt.multi { display: flex; align-items: center; gap: 12px; }
.opt .box { width: 22px; height: 22px; border: 2px solid var(--brand2); border-radius: 6px; flex: none; }
.opt.multi.sel .box { background: var(--brand); box-shadow: inset 0 0 0 3px #fff; }
.tok.used { visibility: hidden; }
.blank.b-ok { background: #128a50 !important; border-color: #9ff07c; }
.blank.b-bad { background: #b12a2e !important; border-color: #ffb4b4; }
.story { background: #f6f3ff; border-radius: 18px; padding: 16px 18px; margin-bottom: 14px; display: flex; gap: 18px; align-items: center; }
.story-img { font-size: 70px; background: #1e1b2e; border-radius: 16px; width: 120px; height: 110px; display: grid; place-items: center; flex: none; }
.story .txt { font-size: 18px; }
.badge-pr { font-size: 12px; letter-spacing: 1px; color: var(--muted); font-weight: 700; display: none; }
.task-h { margin: 6px 0 4px; }
.pill.bug { background: #fde8e8; border-color: #f6c2c3; color: #b12a2e; }
.test { margin-top: 12px; border-radius: 14px; padding: 12px 14px; border: 2px solid; }
.test.ok { background: var(--okbg); border-color: #b6ebcd; }
.test.bad { background: var(--badbg); border-color: #f6c2c3; }
.test .t-h { font-weight: 900; margin-bottom: 6px; }
.t-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-cols pre.out { margin: 0; }
.order-zone.revealed { border-color: var(--ok); background: var(--okbg); }
.iconbtn:disabled { opacity: .3; cursor: default; }
.mark { font-family: 'Cairo'; font-weight: 900; font-size: 26px; color: #fff; background: var(--brand2); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.mark.mk-ok { background: var(--ok); }
.cell { position: relative; }
.mark-sm { position: absolute; bottom: 2px; right: 4px; font-size: 13px; font-weight: 900; color: var(--brand); font-family: 'Cairo'; }
.trace-opts { grid-template-columns: repeat(3, 1fr); }
.trace-opts .opt { text-align: center; font-size: 26px; font-weight: 900; }
.cert .cert-head { width: 100%; text-align: center; }
.cert .letterhead { width: 72%; display: block; margin: 0 auto; }
.cert .credit { font-size: 0.85cqw; color: #8a83a8; margin-top: 0.3cqw; }
.cert .ttl { font-size: 3.1cqw; } .cert .medal { font-size: 3cqw; }
.cert .line { font-size: 1.35cqw; line-height: 1.8; } .cert .stu-name { font-size: 2.6cqw; }
@media print {
  .cert .credit { font-size: 9pt; margin-top: 2pt; }
  .cert .ttl { font-size: 34pt; } .cert .medal { font-size: 32pt; }
  .cert .line { font-size: 15pt; } .cert .stu-name { font-size: 28pt; }
}

/* أزرار نطق المصطلحات الإنجليزية */
.term { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(135deg, #ffe7a3, #ffd060); color: #5a3a00; border: 2px solid #f0b400; border-radius: 999px; padding: 0 10px; font-weight: 700; font-size: .92em; vertical-align: baseline; box-shadow: 0 3px 0 #d79a00; cursor: pointer; line-height: 1.6; margin: 0 2px; }
.term:hover { filter: brightness(1.05); transform: translateY(-1px); }
.term.nudge { animation: nudge 1.6s ease-in-out infinite; }
.term.heard { background: linear-gradient(135deg, #e3f8ec, #bff0d4); border-color: #46a758; color: #155c2e; box-shadow: 0 3px 0 #2f8a46; }
@keyframes nudge { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.12) rotate(-3deg); } 90% { transform: scale(1.08) rotate(3deg); } }
.say-hint { display: flex; align-items: center; gap: 10px; background: #fff8e6; border: 2px solid #ffd060; border-radius: 16px; padding: 6px 12px; margin-bottom: 12px; font-size: 17px; }
.say-hint .sh-face { font-size: 30px; }

/* اسم المطوّر وحساب إنستغرام في الواجهة الرئيسية */
.dev-credit { margin-top: 22px; font-size: 15px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.dev-credit .ig { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 700; text-decoration: none; padding: 4px 10px; border-radius: 999px; border: 2px solid var(--line); background: #fff; }
.dev-credit .ig:hover { border-color: #c4b5fd; }
.dev-credit .ig img { width: 22px; height: 22px; display: block; }
/* زر مشاركة Teams */
.btn.teams { background: #5b5fc7; box-shadow: 0 4px 0 #3d3f99; }
/* لوحة المعلم: الدروس والأسئلة */
.lh-prev { max-width: 100%; max-height: 120px; display: block; border: 2px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; margin-bottom: 10px; }
.ls-list { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow: auto; padding: 2px; }
.ls-item { border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; background: #fff; }
.ls-item.open { border-color: #c4b5fd; }
.ls-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ls-cards { margin: 10px 0 8px; padding: 0 22px 0 0; display: flex; flex-direction: column; gap: 6px; }
.ls-cards li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.ls-sum { flex: 1; min-width: 200px; }
.ls-act { display: flex; gap: 6px; }
.pill.sm { padding: 1px 10px; font-size: 13px; }
.pill.sm.ed { background: #efe9ff; border-color: #c4b5fd; color: #4b23c9; }
.editor-form { display: flex; flex-direction: column; gap: 10px; text-align: right; }
.editor-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.opt-row .field { flex: 1; }
.opt-row .chk { flex-direction: row !important; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }

/* الاسم بثلاث خانات + معاينة الشهادة قبل قفل الاسم */
.name-part { flex: 1 1 120px; min-width: 110px; }
.name-row { flex-wrap: wrap; }
.iconbtn.sm { font-size: 15px; padding: 2px 6px; vertical-align: middle; }
.cert-sample { position: relative; max-width: 480px; margin: 0 auto; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; pointer-events: none; }
.sample-mark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; font-weight: 900; color: rgba(108, 60, 240, .12); transform: rotate(-18deg); }
.warn-box { background: #fff3e0; border: 2px solid #ffcc80; border-radius: 12px; padding: 8px 12px; margin: 8px 0; font-weight: 700; }

/* ===== الهاتف والآيباد ===== */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar::after { content: ''; flex-basis: 100%; order: 1; height: 0; }
  .topbar .who { flex: 1 1 0; min-width: 0; }
  .topbar .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 34px); display: inline-block; vertical-align: middle; }
  .topbar .spacer { display: none; }
  .topbar .pill, .topbar .btn.sm { order: 2; font-size: 14px; padding: 4px 10px; }
  .topbar .iconbtn { padding: 4px 6px; font-size: 20px; }
  .name-part { flex: 1 1 0; min-width: 0; }
}
@media (max-width: 700px) {
  .p-body { padding: 12px 12px 24px; }
  .card .img { font-size: 64px; }
  .card .txt { font-size: 18px; }
  .card .q { font-size: 19px; }
  .card .txt, .card .q, .card .lead, .opt, .tokens { overflow-wrap: anywhere; }
  .opt { font-size: 17px; padding: 12px 14px; }
  .ed-bar { flex-wrap: wrap; gap: 6px; }
  .cell { width: 44px; height: 44px; font-size: 24px; }
  .robot-side { min-width: 0; flex-basis: 100%; }
}
@media (max-width: 700px) {
  .modal-bg { padding: 12px; }
  .modal { padding: 18px; border-radius: 20px; }
}
