/* مناظرة السادسة — عمود واحد (حتّى 720px). شريط علوي ثابت (رجوع · عنوان · لغة).
   الرئيسية: لافتة بالإحصاءات، شبكة المواد الخمس، الامتحانات التجريبية، أزرار سريعة.
   التمرين: نصّ السياق ثم بطاقات الأسئلة التفاعلية (اختيار، عدد، كلمة، كتابة حرّة). الامتحان: مؤقّت ثابت أعلى الصفحة. */
@font-face { font-family: "Readex Pro"; font-weight: 400; font-display: swap; src: url("../fonts/readex-pro-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Readex Pro"; font-weight: 700; font-display: swap; src: url("../fonts/readex-pro-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Readex Pro"; font-weight: 400; font-display: swap; src: url("../fonts/readex-pro-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Readex Pro"; font-weight: 700; font-display: swap; src: url("../fonts/readex-pro-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #F6F4FB; --surface: #FFFFFF; --surface-2: #EFECF7; --ink: #1B1730; --muted: #5F5A78; --line: #E0DCEC;
  --brand: #5B3CC4; --brand-ink: #FFFFFF; --brand-soft: #ECE6FB; --sun: #FFC93C;
  --ok: #1F8A55; --ok-soft: #DDF3E7; --bad: #D1343A; --bad-soft: #FCE3E4; --hint: #9A6700; --hint-soft: #FFF3D1;
  --c-math: #2F6FED; --c-sci: #1E9E61; --c-ar: #E8590C; --c-fr: #7B4AE2; --c-en: #D6336C;
  --shadow: 0 1px 2px rgba(27,23,48,.06), 0 4px 12px rgba(27,23,48,.06);
  --f: "Readex Pro", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110F1C; --surface: #1C1930; --surface-2: #26223D; --ink: #ECE9F7; --muted: #A9A3C4; --line: #332E50;
    --brand: #A48CF5; --brand-ink: #110F1C; --brand-soft: #2A2350; --sun: #FFD25E;
    --ok: #4CC98B; --ok-soft: #12321F; --bad: #FF7A80; --bad-soft: #3D1A1D; --hint: #F3C65A; --hint-soft: #3A2F12;
    --c-math: #7EA6FF; --c-sci: #4FD195; --c-ar: #FF9A5C; --c-fr: #B596FF; --c-en: #FF7FA8;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110F1C; --surface: #1C1930; --surface-2: #26223D; --ink: #ECE9F7; --muted: #A9A3C4; --line: #332E50;
  --brand: #A48CF5; --brand-ink: #110F1C; --brand-soft: #2A2350; --sun: #FFD25E;
  --ok: #4CC98B; --ok-soft: #12321F; --bad: #FF7A80; --bad-soft: #3D1A1D; --hint: #F3C65A; --hint-soft: #3A2F12;
  --c-math: #7EA6FF; --c-sci: #4FD195; --c-ar: #FF9A5C; --c-fr: #B596FF; --c-en: #FF7FA8;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.65 var(--f); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.app { max-width: 720px; margin-inline: auto; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr);
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) 0 8px; }
.top .title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; flex: none; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .flip svg { transform: scaleX(-1); }
.pill { height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--surface); font-weight: 700; font-size: .85rem; }
.view { min-width: 0; display: grid; gap: 14px; align-content: start; padding-top: 4px; animation: in .2s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .view, .pop { animation: none !important; } }

/* ---------- الرئيسية ---------- */
.hero { background: var(--brand); color: var(--brand-ink); border-radius: 22px; padding: 18px; display: grid; gap: 12px; position: relative; overflow: hidden; }
.hero h1 { margin: 0; font-size: 1.45rem; line-height: 1.3; }
.hero p { margin: 0; opacity: .9; font-size: .92rem; }
.hero .deco { position: absolute; inset-inline-end: 8px; top: -10px; font-size: 4.6rem; opacity: .13; font-weight: 700; pointer-events: none; direction: ltr; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: rgba(255,255,255,.14); border-radius: 14px; padding: 8px 4px; text-align: center; }
.stats b { display: block; font-size: 1.35rem; line-height: 1.2; }
.stats span { font-size: .74rem; opacity: .92; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c, var(--brand)); border-radius: inherit; transition: width .4s; }

h2.sec-title { margin: 6px 2px -4px; font-size: 1.05rem; }
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.subj { --c: var(--brand); border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); padding: 14px; text-align: start; display: grid; gap: 8px; border-top: 5px solid var(--c); min-width: 0; }
.subj .ic { width: 46px; height: 46px; border-radius: 14px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; direction: ltr; }
.subj b { font-size: 1rem; line-height: 1.3; }
.subj small { color: var(--muted); font-size: .8rem; }
.subj:last-child:nth-child(odd) { grid-column: 1 / -1; grid-template-columns: auto 1fr; align-items: center; }
.subj:last-child:nth-child(odd) .bar { grid-column: 1 / -1; }
.c-math { --c: var(--c-math); } .c-sci { --c: var(--c-sci); } .c-ar { --c: var(--c-ar); } .c-fr { --c: var(--c-fr); } .c-en { --c: var(--c-en); }

.exams { display: grid; gap: 10px; }
.exam-card { border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); padding: 14px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: start; width: 100%; }
.exam-card .n { width: 46px; height: 46px; border-radius: 14px; background: var(--sun); color: #3A2A00; display: grid; place-items: center; font-weight: 700; font-size: 1.25rem; }
.exam-card b { display: block; }
.exam-card small { color: var(--muted); font-size: .8rem; }
.exam-card .sc { font-weight: 700; color: var(--brand); white-space: nowrap; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { border: 0; border-radius: 14px; padding: 13px 14px; font-weight: 700; background: var(--brand); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; text-align: center; }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); color: #fff; }
.btn .n { background: var(--bad); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 7px; min-width: 22px; line-height: 22px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; display: grid; gap: 6px; padding-top: 6px; }
.foot a, .foot button { color: inherit; background: none; border: 0; text-decoration: underline; font-size: .8rem; padding: 2px 4px; }

/* ---------- قوائم التمارين ---------- */
.list { display: grid; gap: 10px; }
.topic { margin: 8px 2px -2px; font-size: .9rem; color: var(--muted); font-weight: 700; }
.ex { border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; text-align: start; width: 100%; border-inline-start: 5px solid var(--c, var(--brand)); }
.ex .t { font-weight: 700; line-height: 1.4; }
.ex .st { font-size: .95rem; letter-spacing: 1px; color: var(--sun); direction: ltr; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }
.tag { font-size: .75rem; border-radius: 99px; padding: 2px 9px; background: var(--surface-2); color: var(--muted); font-weight: 700; white-space: nowrap; }
.tag.l1 { background: var(--ok-soft); color: var(--ok); } .tag.l2 { background: var(--hint-soft); color: var(--hint); } .tag.l3 { background: var(--bad-soft); color: var(--bad); }
.tag.c { background: var(--c); color: #fff; }

/* ---------- التمرين ---------- */
.ex-head { display: grid; gap: 6px; }
.ex-head h1 { margin: 0; font-size: 1.3rem; line-height: 1.35; }
.content { min-width: 0; overflow-wrap: break-word; }
.content p { margin: 0 0 .55em; } .content p:last-child { margin-bottom: 0; }
.content ul { margin: 0 0 .55em; padding-inline-start: 22px; }
.content .tw { overflow-x: auto; margin: 6px 0 10px; }
.content table { border-collapse: collapse; min-width: 100%; font-size: .92rem; }
.content th, .content td { border: 1px solid var(--line); padding: 6px 9px; text-align: center; white-space: nowrap; }
.content th { background: var(--surface-2); }
.content .fig { text-align: center; margin: 8px 0; } .content .fig svg { max-width: 100%; height: auto; }
.content .fig text { fill: var(--ink); font-family: var(--f); }
.m { direction: ltr; unicode-bidi: isolate; white-space: nowrap; display: inline-block; font-feature-settings: "tnum"; }
.fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.15; margin: 0 2px; font-size: .9em; direction: ltr; }
.fr i { font-style: normal; padding: 0 3px; } .fr i:first-child { border-bottom: 1.5px solid currentColor; }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 2px dotted var(--muted); margin: 0 3px; height: 1.1em; vertical-align: -2px; }
.ctx { background: var(--surface); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); font-size: 1.02rem; line-height: 1.85; }
.lang-note { font-size: .78rem; color: var(--muted); margin: -6px 4px 0; }

.q { background: var(--surface); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); display: grid; gap: 10px; min-width: 0; border: 2px solid transparent; }
.q.is-ok { border-color: var(--ok); } .q.is-bad { border-color: var(--bad); }
.qt { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.qt .num { min-width: 30px; height: 30px; border-radius: 10px; background: var(--c, var(--brand)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; padding: 0 6px; }
.qt .side { display: grid; gap: 3px; justify-items: center; }
.qt .pts { font-size: .7rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.opts { display: grid; gap: 8px; }
.opt { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 11px 13px; text-align: start; min-height: 48px; display: flex; align-items: center; gap: 10px; line-height: 1.45; }
.opt::before { content: ""; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--line); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); } .opt.sel::before { border-color: var(--brand); background: radial-gradient(var(--brand) 45%, transparent 50%); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); } .opt.right::before { border-color: var(--ok); background: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); } .opt.wrong::before { border-color: var(--bad); background: var(--bad); }
.answer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.answer input { flex: 1 1 140px; min-width: 0; height: 50px; border: 1.5px solid var(--line); border-radius: 14px; padding: 0 14px; background: var(--surface); font-size: 1.05rem; }
.answer input:focus { border-color: var(--brand); outline: none; }
.answer .unit { color: var(--muted); font-weight: 700; }
.answer .btn { min-height: 50px; }
textarea { width: 100%; min-height: 110px; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--surface); resize: vertical; line-height: 1.7; }
textarea:focus { border-color: var(--brand); outline: none; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 13px; font-size: .85rem; font-weight: 700; }
.fb { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.fb.ok { color: var(--ok); } .fb.bad { color: var(--bad); }
.hintbox { background: var(--hint-soft); border-radius: 12px; padding: 10px 12px; font-size: .95rem; }
.solbox { background: var(--ok-soft); border-radius: 12px; padding: 10px 12px; border-inline-start: 4px solid var(--ok); }
.solbox .lbl { font-weight: 700; color: var(--ok); font-size: .85rem; display: block; margin-bottom: 2px; }
.self { display: grid; gap: 8px; }
.self .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.self button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 44px; font-weight: 700; }
.self button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.result { background: var(--surface); border-radius: 22px; padding: 20px 16px; box-shadow: var(--shadow); text-align: center; display: grid; gap: 8px; justify-items: center; }
.result .big { font-size: 2.3rem; font-weight: 700; color: var(--brand); line-height: 1.1; direction: ltr; }
.result .stars { font-size: 2rem; letter-spacing: 4px; color: var(--sun); direction: ltr; }
.result .stars .off { color: var(--line); }
.result p { margin: 0; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.pop { animation: pop .35s ease; } @keyframes pop { 50% { transform: scale(1.06); } }

/* ---------- الامتحان ---------- */
.timer { position: sticky; top: calc(58px + env(safe-area-inset-top, 0px)); z-index: 9; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 8px 12px; display: grid; gap: 6px; }
.timer .tline { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.timer .clock { font-size: 1.2rem; direction: ltr; font-feature-settings: "tnum"; }
.timer.low .clock { color: var(--bad); }
.papers { display: grid; gap: 10px; }
.paper { border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); padding: 12px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: start; width: 100%; }
.paper .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; direction: ltr; font-size: .95rem; }
.paper small { color: var(--muted); display: block; font-size: .8rem; }
.paper .sc { font-weight: 700; white-space: nowrap; color: var(--c); }
.note { background: var(--hint-soft); border-radius: 14px; padding: 10px 14px; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.toast { position: fixed; inset-inline: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin-inline: auto; max-width: 420px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; text-align: center; font-weight: 700; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
@media (min-width: 560px) { .subjects { grid-template-columns: repeat(3, 1fr); } .subj:last-child:nth-child(odd) { grid-column: auto; grid-template-columns: none; } .subj:last-child:nth-child(odd) .bar { grid-column: auto; } }
