@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo.ttf') format('truetype'); font-weight: 200 1000; font-display: swap; }

:root {
  --bg: #f4f6fb;
  --card: #fff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0e7490;
  --primary-dark: #155e75;
  --primary-soft: #e0f2f7;
  --ok: #2f9e44;
  --warn: #e8590c;
  --bad: #e03131;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 18px rgba(16, 24, 40, .06);
}

* { 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); font-size: 16px; line-height: 1.7; font-weight: 500; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.35; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; margin-top: 1em; }
h3:first-child { margin-top: 0; }
p { margin: 0 0 .6em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
small { font-size: 13px; }

/* ---------- الإطار ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; }
body.no-shell #app { grid-template-columns: 1fr; }
body.no-shell #sidebar { display: none; }
#sidebar { background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 18px 12px; gap: 10px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; border-bottom: 1px solid #1e293b; }
.brand .logo { font-size: 28px; background: #164e63; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; }
.brand b { color: #fff; display: block; font-size: 16px; }
.brand small { color: #94a3b8; }
#sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
#sidebar nav a { color: #cbd5e1; padding: 10px 12px; border-radius: 10px; display: flex; gap: 10px; align-items: center; }
#sidebar nav a:hover { background: #1e293b; text-decoration: none; }
#sidebar nav a.active { background: var(--primary); color: #fff; }
.who { display: flex; gap: 10px; align-items: center; padding: 10px; background: #1e293b; border-radius: 12px; }
.who .avatar { font-size: 24px; }
.who b { color: #fff; display: block; font-size: 14px; }
.who small { color: #94a3b8; }
#main { overflow-y: auto; overflow-x: hidden; min-width: 0; padding: 26px 30px 60px; }

/* ---------- عناصر عامة ---------- */
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: inherit; border-color: #334155; }
.btn.block { width: 100%; margin: 6px 0; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { font: inherit; border: none; background: transparent; cursor: pointer; padding: 4px 7px; border-radius: 8px; }
.icon-btn:hover { background: #eef2f6; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }

label { display: block; margin: 8px 0; font-size: 14px; color: #374151; }
input, select, textarea { font: inherit; display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=range] { padding: 0; border: none; accent-color: var(--primary); }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 0 0 6px; accent-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.page-head { margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 0; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.section-title { margin: 22px 0 12px; }
.empty { background: #fff; border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px; text-align: center; color: var(--muted); line-height: 2; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.cols .card { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--primary)) 14%, white); color: var(--c, var(--primary)); font-weight: 500; }
.badge { font-size: 13px; padding: 2px 9px; border-radius: 999px; }
.badge.b-sim { background: #e7f5ff; color: #1971c2; }
.badge.b-guide { background: #f1f3f5; color: #495057; }
.badge.b-done { background: #ebfbee; color: #2b8a3e; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; margin-left: 5px; }
.score-pill { display: inline-block; min-width: 46px; text-align: center; font-weight: 600; font-size: 13px; padding: 1px 8px; border-radius: 999px; }
.score-pill.ok { background: #ebfbee; color: #2b8a3e; }
.score-pill.low { background: #fff4e6; color: #d9480f; }
.date-pill { font-size: 13px; background: var(--primary-soft); color: var(--primary-dark); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.warn-line { background: #fff4e6; color: #d9480f; padding: 6px 10px; border-radius: 8px; font-size: 13px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #f1f3f5; flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }
.list li small { margin-inline-start: auto; }

/* الجداول */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { background: #f8fafc; color: #475569; font-weight: 500; text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
table.data.small { font-size: 13px; }
table.data.small th, table.data.small td { padding: 6px 8px; }
table.data.small th { white-space: normal; }
table.data tr.hl td { background: #fff9db; }
table.data .actions { white-space: nowrap; text-align: left; }
table.data .actions a { margin-left: 6px; font-size: 13px; }
table.data.past { opacity: .7; }
tr.low-row td { background: #fff5f5; }
td.qty { white-space: nowrap; }
td.qty b { display: inline-block; min-width: 32px; text-align: center; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 200px; margin: 0; }

/* إحصاءات */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-top: 4px solid var(--primary); }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.alert { border-top-color: var(--warn); }
.stat.alert b { color: var(--warn); }

/* بطاقات التجارب */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.exp-card { display: flex; flex-direction: column; gap: 6px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; color: var(--ink); border-top: 4px solid var(--c); transition: .15s; }
.exp-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 8px 24px rgba(16,24,40,.1); }
.exp-card-top { display: flex; justify-content: space-between; align-items: center; }
.subj-icon { font-size: 26px; }
.exp-card h3 { margin: 4px 0 0; font-size: 16px; }
.exp-card .meta { color: var(--muted); font-size: 13px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* شاشة الدخول */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; background: radial-gradient(circle at 20% 10%, #cff4fc 0, transparent 40%), radial-gradient(circle at 80% 90%, #e5dbff 0, transparent 40%), var(--bg); margin: -26px -30px -60px; }
.login-hero { text-align: center; margin-bottom: 26px; }
.hero-icons { font-size: 40px; letter-spacing: 10px; }
.login-hero h1 { font-size: 38px; margin: 6px 0; color: #0f172a; }
.login-hero p { color: var(--muted); font-size: 17px; }
.school-name { display: inline-block; background: #fff; padding: 4px 16px; border-radius: 999px; box-shadow: var(--shadow); }
.login-cards { display: grid; grid-template-columns: repeat(2, minmax(300px, 380px)); gap: 20px; }
.login-cards .card { padding: 24px; }

/* صفحة التجربة */
.exp-head { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 14px; border-inline-start: 6px solid var(--c); }
.exp-head .back { font-size: 13px; }
.exp-title { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.exp-title > div { flex: 1; }
.exp-title h1 { font-size: 23px; margin: 0 0 4px; }
.big-icon { font-size: 42px; }
.exp-head .meta { display: flex; gap: 14px; color: var(--muted); font-size: 14px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; background: #fff; padding: 5px; border-radius: 12px; box-shadow: var(--shadow); width: fit-content; }
.tabs button { font: inherit; border: none; background: transparent; padding: 8px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--primary); color: #fff; }
.guide { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.guide .card { margin: 0; }
.guide .card.wide { grid-column: 1 / -1; }
.theory { line-height: 1.9; }
.tools, .safety { padding-inline-start: 20px; margin: 0 0 14px; }
.tools li { margin: 4px 0; }
.tools li small { color: var(--muted); margin-inline-start: 6px; }
.tools li.ok small { color: var(--ok); }
.tools li.low small { color: var(--warn); }
.tools li.missing small { color: var(--bad); }
.safety li { margin: 4px 0; color: #9c3d0a; }
.steps { padding-inline-start: 22px; margin: 0; columns: 2; column-gap: 40px; }
.steps li { margin: 0 0 8px; break-inside: avoid; }

.q { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; }
.q.right { border-color: #b2f2bb; background: #f4fdf5; }
.q.wrong { border-color: #ffc9c9; background: #fff8f8; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.opt { margin: 0; padding: 7px 10px; border-radius: 9px; background: #f8fafc; cursor: pointer; display: flex; align-items: center; }
.opt.correct { background: #d3f9d8; }
.opt.chosen-wrong { background: #ffe3e3; }

.result-box { padding: 10px 14px; border-radius: 12px; margin: 10px 0; }
.result-box.good { background: #ebfbee; border: 1px solid #b2f2bb; }
.result-box.mid { background: #fff9db; border: 1px solid #ffe066; }
.result-box ul { margin: 6px 0 0; padding-inline-start: 20px; }

/* التقرير */
.report header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 12px; gap: 12px; }
.report h2 { margin: 0; }
.report h3 { border-inline-start: 4px solid var(--primary); padding-inline-start: 8px; margin: 16px 0 8px; }
.report-school { font-weight: 600; text-align: left; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
table.kv th, table.kv td { border: 1px solid var(--line); padding: 6px 10px; text-align: right; }
table.kv th { background: #f8fafc; font-weight: 500; width: 22%; }
.conclusion { white-space: normal; }

/* النوافذ والرسائل */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal footer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: .4s; max-width: 420px; }
.toast.warn { background: #d9480f; }
.toast.error { background: #c92a2a; }
.toast.hide { opacity: 0; transform: translateY(10px); }

/* ---------- المحاكاة ---------- */
.sim { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(330px, 1fr); gap: 16px; align-items: start; }
.sim.balanced { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.sim-stage, .sim-panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.sim-stage { position: sticky; top: 0; }
.sim-stage svg, .sim-stage canvas { display: block; max-width: 100%; margin: 0 auto; }
.sim canvas, .sim svg, input[type=range] { direction: ltr; }
.sim-toolbar { display: flex; flex-direction: column; gap: 8px; }
.plot { width: 100%; height: 230px; margin: 10px 0; }
.lcd { background: #10261a; color: #8ce99a; border-radius: 10px; padding: 6px 12px; text-align: center; font-family: Consolas, monospace; min-width: 130px; }
.lcd small { display: block; color: #a9e3b5; font-family: 'Cairo', sans-serif; }
.lcd b { font-size: 24px; letter-spacing: 1px; }
.readouts, .meters { display: flex; gap: 10px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.meters .lcd { flex: 1; }
.info-box { background: #f1f8fb; border: 1px solid #c5e6ef; border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.9; }
.formula { background: #f8f9fa; border-radius: 8px; padding: 6px 12px; text-align: center; font-family: Consolas, 'Cairo', monospace; margin: 8px 0; font-size: 14px; }
.classify label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 4px 0; }
.classify select { width: 130px; margin: 0; }

/* الكواشف */
.rack { width: 100%; max-width: 640px; }
.rack .tube { cursor: pointer; }
.rack .tube:hover path:last-of-type { stroke: var(--primary); }
.rack path { transition: fill .6s; }
.uni-chart { display: grid; grid-template-columns: repeat(15, 1fr); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.uni-chart div { height: 30px; display: grid; place-items: center; }
.uni-chart span { color: #fff; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* المعايرة */
.titration svg { height: 520px; }
#drop.falling { animation: drop .45s ease-in; }
@keyframes drop { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(70px); } }

/* الدائرة */
.circuit { width: 100%; max-width: 560px; }

/* المجهر */
.scope { text-align: center; }
.scope canvas { width: 440px; height: 440px; border-radius: 50%; cursor: grab; box-shadow: 0 0 0 10px #343a40, 0 0 0 14px #868e96; margin: 14px auto !important; }
.scope canvas:active { cursor: grabbing; }
.scope-info { margin-top: 8px; }
.focus-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.focus-row span { flex: 1; }
.focus-row .btn { padding: 4px 16px; }
.task-now { background: #fff9db; border: 1px solid #ffe066; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }

/* الكشف عن الغذاء */
.bench { display: flex; gap: 16px; align-items: flex-start; }
.bench svg { width: 230px; flex: none; }
.bench-controls { flex: 1; }
.bench-controls h4 { margin: 12px 0 6px; }
.bench-controls h4:first-child { margin-top: 0; }
.obs-now { margin-top: 12px; padding: 8px 12px; background: #f8f9fa; border-radius: 10px; min-height: 40px; }
.bubbles circle { fill: #fff; opacity: .8; animation: bubble 1.2s infinite ease-in; }
.bubbles circle:nth-child(2) { animation-delay: .3s; }
.bubbles circle:nth-child(3) { animation-delay: .6s; }
.bubbles circle:nth-child(4) { animation-delay: .9s; }
@keyframes bubble { 0% { transform: translateY(0); opacity: .9; } 100% { transform: translateY(-110px); opacity: 0; } }
.grid-table td { text-align: center; }
.grid-table td:first-child { text-align: right; white-space: nowrap; }
.mark-cell { cursor: pointer; }
.mark-cell small { display: block; color: var(--muted); font-size: 13px; }
.mark-cell .mark { display: inline-block; min-width: 24px; margin-top: 2px; background: #e9ecef; border-radius: 6px; }
.mark-cell:hover .mark { background: var(--primary-soft); }
td.right { background: #ebfbee !important; }
td.wrong { background: #ffe3e3 !important; }

/* البوابات المنطقية */
.logic-board { width: 100%; max-width: 560px; margin: 14px auto; }
.logic-board .w { stroke: #adb5bd; stroke-width: 3; fill: none; }
.logic-board .w.on { stroke: #f59f00; }
.gate-body path, .gate-body circle { fill: #fff; stroke: #343a40; stroke-width: 2.5; }
.gate-body path.open { fill: none; }
.sw { cursor: pointer; }
.sw rect { fill: #e9ecef; stroke: #868e96; }
.sw rect.on { fill: #ffd43b; stroke: #f59f00; }
.sw text, .logic-board .lbl { font-size: 13px; font-family: Consolas, monospace; fill: #343a40; }
.led { fill: #495057; stroke: #343a40; stroke-width: 2; }
.led.on { fill: #ffd43b; filter: drop-shadow(0 0 8px #ffd43b); }
.expr { text-align: center; font-family: Consolas, 'Cairo', monospace; font-size: 16px; background: #f8f9fa; border-radius: 8px; padding: 8px; }
table.truth { width: auto; min-width: 220px; margin: 0 auto; }
table.truth th, table.truth td { text-align: center; font-family: Consolas, monospace; font-size: 15px; }
.out-cell { cursor: pointer; font-weight: 700; background: #f1f3f5; }
.out-cell:hover { background: var(--primary-soft); }
.progress-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #f1f3f5; color: var(--muted); }
.pchip.ok { background: #ebfbee; color: #2b8a3e; }

/* النظام الثنائي */
.bits { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 18px; }
.bit { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 12px; width: 62px; padding: 8px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.bit .bulb { width: 30px; height: 30px; border-radius: 50%; background: #495057; transition: .2s; }
.bit.on .bulb { background: #ffd43b; box-shadow: 0 0 14px #ffd43b; }
.bit b { font-family: Consolas, monospace; font-size: 20px; }
.bit small { color: var(--muted); }
.bin-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.bin-readout div { background: #f8f9fa; border-radius: 10px; padding: 8px; }
.bin-readout small { display: block; color: var(--muted); }
.bin-readout b { font-family: Consolas, monospace; font-size: 22px; }
.sum { text-align: center; font-family: Consolas, monospace; margin: 12px 0; color: var(--primary-dark); font-size: 16px; }
.challenge { background: #f8fafc; border-radius: 12px; padding: 12px 14px; }
.challenge .big { font-size: 22px; font-family: Consolas, monospace; color: var(--primary-dark); }
.challenge input { max-width: 220px; }


/* ---------- الإطار الجديد ---------- */
#sidebar a.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.side-search input { background: #1e293b; border-color: #334155; color: #e2e8f0; margin: 0; }
.nav-stage { color: #94a3b8; font-size: 13px; margin: 12px 8px 4px; font-weight: 600; }
#sidebar nav a.sub { padding: 7px 14px; justify-content: space-between; font-size: 14px; }
#sidebar nav a.sub small { background: #1e293b; color: #94a3b8; border-radius: 999px; padding: 0 8px; }
#sidebar nav a.sub.active small { background: rgba(255,255,255,.2); color: #fff; }
.hero { text-align: center; padding: 26px 20px 10px; background: radial-gradient(circle at 20% 0, #cff4fc 0, transparent 45%), radial-gradient(circle at 80% 100%, #e5dbff 0, transparent 45%); border-radius: 20px; margin-bottom: 8px; }
.hero h1 { font-size: 36px; margin: 4px 0; }
.hero p { color: var(--muted); font-size: 16px; }
.hero-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.hero-stats span { background: #fff; padding: 4px 14px; border-radius: 999px; box-shadow: var(--shadow); border-bottom: 3px solid var(--c, var(--primary)); }
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.grade-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); transition: .15s; }
.grade-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 8px 24px rgba(16,24,40,.1); }
.grade-card b { font-size: 17px; }
.subj-dots i { font-style: normal; margin-left: 4px; }
.subj-tabs { margin-bottom: 6px; }
.chapter-title { color: var(--muted); font-size: 15px; margin: 14px 0 8px; font-weight: 500; }
.badge.b-book { background: #fff9db; color: #946200; }
.crumbs { font-size: 13px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.pager .btn { max-width: 48%; overflow: hidden; text-overflow: ellipsis; }

/* محرك الطاولة */
.bench-svg { width: 100%; max-height: 420px; }
.bench-svg .bub { animation: rise 1.4s infinite ease-in; }
@keyframes rise { 0% { transform: translateY(0); opacity: .9; } 100% { transform: translateY(-90px); opacity: 0; } }
.bench-svg .steam path { fill: none; stroke: #adb5bd; stroke-width: 2; animation: steam 1.6s infinite; }
@keyframes steam { 0% { opacity: .2; transform: translateY(4px); } 50% { opacity: .8; } 100% { opacity: 0; transform: translateY(-10px); } }
.bench-svg .flame { animation: flicker .3s infinite alternate; transform-box: fill-box; transform-origin: center bottom; }
@keyframes flicker { from { transform: scale(1); } to { transform: scale(1.12); } }
.bench-svg .liq, .bench-svg rect, .bench-svg ellipse { transition: fill .7s, y .7s, height .7s, rx .7s, ry .7s, cy .7s; }
.notes { margin: 0; padding-inline-start: 22px; }
.notes li { margin: 4px 0; }
.progress-bar { height: 8px; background: #edf2f7; border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-bar div { height: 100%; background: var(--primary); transition: width .4s; }
.choices { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.choice { font: inherit; text-align: right; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #f8fafc; cursor: pointer; transition: .15s; }
.choice:hover { border-color: var(--primary); background: var(--primary-soft); }
.waiting { padding: 18px; text-align: center; background: #fff9db; border-radius: 12px; font-size: 16px; }

/* محرك القياس */
.measure-svg { width: 100%; max-height: 360px; background: #fbfcfe; border-radius: 12px; }

/* التصنيف والترتيب */
.pool { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: #f8fafc; border-radius: 12px; min-height: 60px; margin: 10px 0; }
.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.bin { border: 2px dashed #cbd5e1; border-radius: 14px; padding: 10px; min-height: 120px; cursor: pointer; transition: .15s; }
.bin:hover { border-color: var(--primary); background: #f0fbfd; }
.bin h4 { margin: 0 0 8px; text-align: center; }
.bin-items { display: flex; flex-wrap: wrap; gap: 6px; }
.card-item { font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 10px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card-item .ic { font-size: 22px; }
.card-item.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.card-item.right { background: #ebfbee; border-color: #8ce99a; }
.card-item.wrong { background: #ffe3e3; border-color: #ffa8a8; }
.seq { list-style: none; counter-reset: s; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.seq li { counter-increment: s; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.seq li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; font-weight: 700; flex: none; }
.seq li.right { background: #ebfbee; border-color: #8ce99a; }
.seq li.wrong { background: #ffe3e3; border-color: #ffa8a8; }
.seq-label { flex: 1; display: flex; align-items: center; gap: 8px; }
.seq-label .ic { font-size: 24px; }
.seq-btns { display: flex; gap: 2px; }
.lines { height: 90px; border-bottom: 1px dashed #adb5bd; background: repeating-linear-gradient(transparent, transparent 29px, #e9ecef 30px); }


/* محرك تتبّع البرامج */
.code-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.code { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 12px 34px 12px 14px; margin: 0; font-family: Consolas, 'Cairo', monospace; font-size: 15px; line-height: 1.9; }
.code[dir=ltr] { padding: 12px 14px 12px 40px; }
.code li { padding: 0 8px; border-radius: 6px; }
.code li::marker { color: #64748b; }
.code li.cur { background: #fab005; color: #0f172a; }
.code code { font-family: inherit; white-space: pre-wrap; }
.trace-io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.trace-io h4 { margin: 0 0 6px; }
.screen { background: #10261a; color: #8ce99a; border-radius: 10px; padding: 10px; min-height: 80px; margin: 0; font-family: Consolas, monospace; font-size: 15px; white-space: pre-wrap; }
.reaction { text-align: center; }
.reaction svg { height: 420px; }
.big-btn { font-size: 20px; padding: 12px 40px; margin: 10px auto; display: block; }


/* محرر HTML والجدول الإلكتروني والتهجين */
.code-editor { width: 100%; height: 420px; font-family: Consolas, monospace; font-size: 14px; background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 12px; resize: vertical; tab-size: 2; }
.html-view { width: 100%; height: 260px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { padding: 6px 8px; border-radius: 8px; margin-bottom: 4px; background: #f8fafc; }
.tasks li.ok { background: #ebfbee; }
.fbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.fbar .addr { min-width: 46px; text-align: center; font-family: Consolas, monospace; background: #f1f3f5; padding: 7px; border-radius: 8px; }
.fbar .fx { font-style: italic; color: var(--muted); }
.fbar input { margin: 0; font-family: Consolas, monospace; }
table.sheet { border-collapse: collapse; font-size: 14px; }
table.sheet th { background: #f1f3f5; color: #495057; font-weight: 500; padding: 4px 8px; border: 1px solid #dee2e6; min-width: 28px; }
table.sheet td { border: 1px solid #dee2e6; padding: 4px 8px; min-width: 86px; height: 30px; cursor: cell; direction: rtl; }
table.sheet td.num { direction: ltr; text-align: left; }
table.sheet td.hdr { font-weight: 700; background: #f8f9fa; }
table.sheet td.f { color: #1971c2; }
table.sheet td.sel { outline: 2px solid #2f9e44; outline-offset: -2px; background: #ebfbee; }
table.punnett { border-collapse: collapse; margin: 12px auto; font-size: 18px; }
table.punnett th, table.punnett td { border: 2px solid #adb5bd; width: 90px; height: 70px; text-align: center; }
table.punnett th { background: #f1f3f5; font-size: 20px; }


/* الرسوم التوضيحية */
.bio-fig { margin: 0; }
.fig-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.fig-tools b { font-size: 16px; }
.fig-tools .btn { padding: 5px 12px; font-size: 13px; }
.art-svg { width: 100%; height: auto; display: block; direction: ltr; background: #fcfdfe; border-radius: 12px; font-family: 'Cairo', sans-serif; }
.bio-fig .art-svg { max-height: 460px; }
.bio-fig figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; text-align: center; }
.lab line { stroke: #495057; stroke-width: 1.2; }
.lab circle { fill: #212529; }
.lab text { font-size: 14px; fill: #212529; font-weight: 500; }
.bio-fig.quiz .lab text { opacity: 0; transition: opacity .2s; }
.bio-fig.quiz .lab.shown text { opacity: 1; fill: #c2255c; }
.bio-fig.quiz .lab { cursor: pointer; }
.bio-fig.quiz .lab circle { fill: #e64980; r: 5; }
.fig-panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; margin-bottom: 14px; }
.fig-panel summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fig-panel .bio-fig { max-width: 760px; margin: 10px auto 4px; }
.fig-switch { display: inline-flex; gap: 6px; flex-wrap: wrap; font-weight: 400; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.fig-grid .bio-fig { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.art-thumb { display: inline-block; width: 110px; flex: none; }
.art-thumb .art-svg { background: transparent; }
.seq li { min-height: 60px; }


/* مكتبة الرسوم */
.gal-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.gal-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-top: 1px solid #f1f3f5; padding-top: 8px; }
.gal-uses { font-size: 13px; line-height: 1.9; }
#print-root .bio-fig .art-svg { max-height: none; }
#print-root .fig-quiz { display: none; }
@media (max-width: 1150px) {
  .sim, .sim.balanced { grid-template-columns: 1fr; }
  .sim-stage { position: static; }
  .guide { grid-template-columns: 1fr; }
  .steps { columns: 1; }
}

/* الطباعة */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  #app, #toasts, .modal-backdrop { display: none !important; }
  #print-root { display: block; font-size: 13px; }
  #print-root table { page-break-inside: auto; }
}

/* الرسوم حسب المنهج */
.gal-grades { margin: -6px 0 16px; }
.gal-grades:empty { display: none; }
.gal-chap { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.gal-chap small { font-size: 13px; background: #f1f3f5; padding: 2px 9px; border-radius: 999px; }
.section-title .gal-to-grade { font-size: 13px; padding: 4px 12px; margin-inline-start: 10px; vertical-align: middle; }
/* الأداء: لا تُرسم بطاقات الرسوم البعيدة عن الشاشة */
.gal-card { content-visibility: auto; contain-intrinsic-size: 420px 520px; }

/* ---------- الهاتف والتابلت ---------- */
#topbar, #scrim { display: none; }
.fig-grid { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
@media (max-width: 860px) {
  html, body { height: auto; }
  #topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; background: #0f172a; padding: 8px 12px; }
  #topbar .btn { background: #1e293b; color: #fff; border-color: #334155; font-size: 18px; padding: 4px 12px; }
  .top-brand { color: #fff; font-weight: 700; font-size: 16px; }
  #app { display: block; height: auto; }
  #main { overflow: visible; padding: 16px 14px 60px; }
  #sidebar { position: fixed; top: 0; bottom: 0; right: 0; width: min(300px, 86vw); z-index: 60; transform: translateX(105%); transition: transform .25s ease; box-shadow: -8px 0 30px rgba(0,0,0,.3); }
  body.menu-open #sidebar { transform: none; }
  body.menu-open #scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; }
  h1 { font-size: 21px; }
  .page-head.row { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .tabs { width: 100%; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
  .grid { grid-template-columns: 1fr !important; }
  .gal-foot { flex-direction: column; }
  .section-title .gal-to-grade { margin: 6px 0 0; }
  .sim canvas, .sim svg { max-width: 100%; height: auto; }
  .modal { width: 100%; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  .chip { font-size: 12.5px; padding: 5px 10px; }
  .gal-card, .fig-grid .bio-fig { padding: 10px; }
}
.exp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.exp-title > .exp-actions { flex: 0 0 auto; }
@media (max-width: 860px) {
  .exp-title { flex-wrap: wrap; gap: 10px; }
  .exp-title > div:not(.exp-actions) { flex: 1 1 200px; }
  .exp-title > .exp-actions { flex: 1 1 100%; }
  .exp-title h1 { font-size: 20px; }
  .big-icon { font-size: 32px; }
}
/* محتوى ثابت للبحث يُستبدل فور تشغيل التطبيق */
.seo-static { max-width: 760px; }
.seo-static h1 { margin-bottom: 8px; }
@media (max-width: 860px) {
  .sim, .sim > *, .sim-panel, .sim-stage { min-width: 0; max-width: 100%; }
  .sim table { display: block; overflow-x: auto; max-width: 100%; }
  .bench { max-width: 100%; overflow-x: auto; }
  .pager { flex-wrap: wrap; }
  .pager .btn { white-space: normal; flex: 1 1 100%; }
}

/* صور الرموز (Twemoji) بدل الإيموجي النصي */
img.emo { height: 1.2em; width: 1.2em; vertical-align: -0.22em; display: inline-block; margin: 0 0.05em; pointer-events: none; user-select: none; }
/* خيار أو بطاقة فيها صورة فقط ← صورة كبيرة واضحة */
.lq-opt img.emo.emo-solo, .mitem img.emo.emo-solo, .sort-card img.emo.emo-solo, .kg-opt img.emo.emo-solo { height: 3.2em; width: 3.2em; vertical-align: middle; }

/* تبويب «صورة حقيقية» */
.real-photo { margin: 0; padding: 12px; text-align: center; }
.real-photo img { max-width: 100%; max-height: 58vh; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.15); background: #eef1f5; }
.real-photo figcaption { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.real-photo small { color: var(--muted, #6b7280); font-size: 13px; direction: rtl; }
