/* Upskill Arabia — app pages (course player, sign in, dashboard, editor, certificate).
   Same brand tokens as the homepage stylesheet. */
:root {
  --primary: #4338CA; --primary-dark: #362CA0; --primary-soft: #EEF0FD;
  --teal: #0F8F80; --teal-soft: #E3F6F3;
  --amber: #B45309; --amber-soft: #FEF3E2;
  --red: #B42318; --red-soft: #FDECEA;
  --ink: #161A2E; --ink-2: #474C66; --ink-3: #6B7088;
  --line: #E3E5EF; --line-soft: #EEF0F6;
  --paper: #F7F8FC; --white: #FFFFFF;
  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22,26,46,.05), 0 6px 20px rgba(22,26,46,.06);
  --font: 'Inter', system-ui, sans-serif;
  --font-head: 'Poppins', 'Inter', system-ui, sans-serif;
  --hdr: 64px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.25; margin: 0; text-wrap: balance; color: var(--ink); }
p { margin: 0; }
a { color: var(--primary); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons & form controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: .92rem; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .2s, border-color .2s, color .2s, transform .2s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: var(--white); border-color: var(--line); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--primary); }
.btn-danger { background: var(--white); border-color: #F3C9C4; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 7px 14px; font-size: .84rem; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.input, .field input, .field select, .field textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); font-size: .95rem; transition: border-color .2s; }
.field textarea, textarea.input { resize: vertical; min-height: 110px; line-height: 1.55; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.hint { font-size: .8rem; color: var(--ink-3); }
.form-error { color: var(--red); font-size: .88rem; min-height: 1.2em; }

/* ---------- Header ---------- */
#appHeader { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.hdr-inner { max-width: 1240px; margin: 0 auto; height: var(--hdr); padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.hdr-nav { display: flex; align-items: center; gap: 16px; }
.hdr-link { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .92rem; }
.hdr-link:hover { color: var(--primary); }
.hdr-user { font-size: .88rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.role-chip { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 999px; }
.preview-pill { font-size: .78rem; font-weight: 600; background: var(--amber-soft); color: var(--amber); padding: 5px 12px; border-radius: 999px; }

.page-message { max-width: 560px; margin: 90px auto; padding: 0 20px; text-align: center; }
.page-message h1 { font-size: 1.6rem; margin-bottom: 12px; }
.page-message p { color: var(--ink-2); }
.pm-actions { margin-top: 24px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.loading { padding: 80px 20px; text-align: center; color: var(--ink-3); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: .9rem; font-weight: 500; z-index: 200; transition: opacity .25s, transform .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--red); }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .9rem; }
.banner-info { background: var(--amber-soft); color: #7A3A06; }

/* ---------- Course page ---------- */
.course-hero { position: relative; background: var(--ink); color: #fff; overflow: hidden; }
.course-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .32; }
.course-hero-inner { position: relative; max-width: 1240px; margin: 0 auto; padding: 44px 20px 40px; }
.course-hero .crumb { color: rgba(255,255,255,.75); font-size: .85rem; text-decoration: none; }
.course-hero .crumb:hover { color: #fff; }
.course-hero h1 { color: #fff; font-size: clamp(1.6rem, 3.4vw, 2.4rem); margin: 10px 0 8px; max-width: 760px; }
.course-hero .tagline { color: rgba(255,255,255,.88); font-size: 1.05rem; max-width: 640px; }
.course-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.course-facts span { background: rgba(255,255,255,.14); padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 500; }

.course-layout { max-width: 1240px; margin: 0 auto; padding: 28px 20px 80px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; align-items: start; }
.course-nav { position: sticky; top: calc(var(--hdr) + 20px); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-height: calc(100vh - var(--hdr) - 40px); overflow-y: auto; }
.progress-head { display: flex; justify-content: space-between; font-size: .84rem; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-bottom: 18px; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--teal)); border-radius: 999px; transition: width .4s; }
.nav-module + .nav-module { margin-top: 14px; }
.nav-module h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; font-family: var(--font); font-weight: 700; }
.nav-item { width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: left; background: none; border: 0; padding: 7px 8px; border-radius: 8px; font-size: .88rem; color: var(--ink-2); cursor: pointer; line-height: 1.4; }
.nav-item:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.nav-item[aria-current="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item:disabled { cursor: default; opacity: .55; }
.nav-dot { flex: 0 0 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .65rem; margin-top: 1px; }
.nav-item.done .nav-dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.nav-toggle { display: none; }

.course-main { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 4vw, 44px); min-height: 420px; }
.item-kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.course-main > h2 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); margin: 6px 0 22px; }
.item-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line-soft); }

.prose { max-width: 70ch; font-size: 1.02rem; color: #2A2F45; }
.prose > * + * { margin-top: 16px; }
.prose ul { padding-left: 1.2em; margin-bottom: 0; }
.prose li + li { margin-top: 6px; }
.prose strong { color: var(--ink); }
.media-video, .media-img { margin: 24px 0; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-video figcaption, .media-img figcaption { font-size: .84rem; color: var(--ink-3); margin-top: 8px; }
.media-img img { border-radius: var(--radius-sm); }
.diagram-steps { list-style: none; padding: 0; margin: 22px 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: none; }
.diagram-steps li { flex: 1 1 120px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; padding: 14px 10px; background: var(--primary-soft); border-radius: var(--radius-sm); position: relative; font-weight: 600; font-size: .9rem; color: var(--ink); }
.diagram-steps li:not(:last-child)::after { content: '→'; position: absolute; right: -9px; top: 50%; transform: translateY(-50%); color: var(--primary); font-weight: 700; z-index: 1; }
.ds-n { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .78rem; }
.diagram-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 22px 0; }
.dg-cell { border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.dg-cell span { font-size: .9rem; color: var(--ink-2); }
.reflect { background: var(--amber-soft); border-radius: var(--radius-sm); padding: 16px 18px; margin: 26px 0 0; }
.reflect-label { display: block; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); margin-bottom: 6px; }

/* Quiz */
.quiz-intro { color: var(--ink-2); margin-bottom: 22px; }
.quiz-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; counter-reset: q; }
.q { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; counter-increment: q; }
.q.is-correct { border-color: #9CDCD2; }
.q.is-wrong { border-color: #F3C9C4; }
.q-type { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; }
.q-type::before { content: 'Q' counter(q) ' · '; color: var(--primary); }
.q-text { font-weight: 600; margin-bottom: 14px; line-height: 1.5; }
.q-options { display: flex; flex-direction: column; gap: 8px; }
.q-options-row { flex-direction: row; }
.q-options-row .q-opt { flex: 1; text-align: center; }
.q-opt { text-align: left; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); cursor: pointer; transition: border-color .15s, background .15s; line-height: 1.45; }
.q-opt:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.q-opt:disabled { cursor: default; }
.q-opt.opt-correct { border-color: var(--teal); background: var(--teal-soft); color: var(--ink); font-weight: 600; }
.q-opt.opt-wrong { border-color: var(--red); background: var(--red-soft); }
.fill-input { display: inline-block; width: 11em; max-width: 100%; margin: 0 6px; padding: 5px 10px; border: 0; border-bottom: 2px solid var(--primary); background: var(--primary-soft); border-radius: 6px 6px 0 0; font-weight: 600; }
.fill-input:focus { outline: none; background: #E2E5FB; }
.fill-correct { border-color: var(--teal); background: var(--teal-soft); }
.fill-wrong { border-color: var(--red); background: var(--red-soft); text-decoration: line-through; }
.match-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--paper); }
.match-row select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.match-left { font-weight: 600; font-size: .92rem; }
.match-row.row-correct { background: var(--teal-soft); }
.match-row.row-wrong { background: var(--red-soft); }
.match-fix { grid-column: 2; font-size: .84rem; color: var(--teal); font-weight: 600; }
.q-check { margin-top: 4px; }
.q-feedback { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: .92rem; background: var(--paper); }
.is-correct .q-feedback strong { color: var(--teal); }
.is-wrong .q-feedback strong { color: var(--red); }
.quiz-summary { display: none; margin-top: 22px; padding: 16px 18px; border-radius: var(--radius); background: var(--primary-soft); }
.quiz-summary.show { display: block; }

/* Gate + final task */
.gate { text-align: center; padding: 30px 10px; }
.gate h2 { margin-bottom: 10px; }
.gate p { color: var(--ink-2); max-width: 46ch; margin: 0 auto 22px; }
.overview-modules { text-align: left; margin-top: 30px; display: grid; gap: 10px; }
.overview-modules div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; }
.overview-modules strong { display: block; }
.overview-modules span { font-size: .85rem; color: var(--ink-3); }
.task-form { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; max-width: 70ch; }
.status-card { border-radius: var(--radius); padding: 18px 20px; margin-top: 24px; }
.status-submitted { background: var(--primary-soft); }
.status-approved { background: var(--teal-soft); }
.status-revision { background: var(--amber-soft); }
.status-card h3 { font-size: 1.05rem; margin-bottom: 6px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: calc(100vh - var(--hdr)); display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-2); font-size: .94rem; margin-bottom: 22px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper); border-radius: 999px; padding: 4px; margin-bottom: 22px; }
.auth-tabs button { border: 0; background: none; padding: 8px; border-radius: 999px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--ink-2); }
.auth-tabs button[aria-selected="true"] { background: var(--white); color: var(--primary); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: .88rem; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- Dashboard ---------- */
.dash { max-width: 1240px; margin: 0 auto; padding: 32px 20px 80px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-head h1 { font-size: 1.7rem; }
.dash-head p { color: var(--ink-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 16px; font-weight: 600; font-size: .92rem; color: var(--ink-3); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); border-color: var(--primary); }
.tab-count { background: var(--amber); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: .72rem; margin-left: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-card b { display: block; font-family: var(--font-head); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat-card span { font-size: .84rem; color: var(--ink-3); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.c-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: box-shadow .2s, transform .2s; }
.c-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.c-card img { aspect-ratio: 16 / 9; object-fit: cover; }
.c-card-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.c-card h3 { font-size: 1rem; }
.c-card p { font-size: .88rem; color: var(--ink-2); flex: 1; }
.c-card .progress-bar { margin: 4px 0 0; }
.c-card .meta { font-size: .8rem; color: var(--ink-3); display: flex; justify-content: space-between; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.1rem; margin-bottom: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select, .toolbar input { padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data .sub { display: block; font-size: .8rem; color: var(--ink-3); }
.mini-bar { display: inline-block; width: 80px; height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.mini-bar span { display: block; height: 100%; background: var(--teal); }
.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-submitted { background: var(--primary-soft); color: var(--primary); }
.pill-approved { background: var(--teal-soft); color: var(--teal); }
.pill-revision { background: var(--amber-soft); color: var(--amber); }
.pill-draft { background: var(--line-soft); color: var(--ink-3); }
.pill-live { background: var(--teal-soft); color: var(--teal); }
.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; }
.review { border-top: 1px solid var(--line-soft); padding: 16px 0; display: grid; gap: 10px; }
.review:first-of-type { border-top: 0; }
.review-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.review-work { background: var(--paper); border-radius: var(--radius-sm); padding: 12px 14px; white-space: pre-wrap; font-size: .92rem; max-height: 260px; overflow: auto; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Editor ---------- */
.editor { max-width: 1000px; margin: 0 auto; padding: 28px 20px 120px; }
.editor-bar { position: sticky; top: var(--hdr); z-index: 40; background: rgba(247,248,252,.95); backdrop-filter: blur(8px); padding: 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.editor-bar h1 { font-size: 1.25rem; }
.save-state { font-size: .84rem; color: var(--ink-3); }
.save-state.dirty { color: var(--amber); font-weight: 600; }
.ed-section { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.ed-section > h2 { font-size: 1.05rem; margin-bottom: 14px; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ed-grid .wide { grid-column: 1 / -1; }
.ed-module { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; background: var(--white); }
.ed-module-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); background: var(--paper); border-radius: var(--radius) var(--radius) 0 0; }
.ed-module-head input { flex: 1; font-weight: 600; }
.ed-items { padding: 12px 16px 16px; display: grid; gap: 10px; }
.ed-item { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ed-item > summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: .92rem; }
.ed-item > summary::-webkit-details-marker { display: none; }
.ed-item > summary::before { content: '▸'; color: var(--ink-3); transition: transform .15s; }
.ed-item[open] > summary::before { transform: rotate(90deg); }
.ed-item-type { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.ed-item-type.quiz { background: var(--amber-soft); color: var(--amber); }
.ed-item-body { padding: 4px 14px 16px; display: grid; gap: 12px; }
.ed-row-actions { display: flex; gap: 6px; margin-left: auto; }
.icon-btn { border: 1px solid var(--line); background: var(--white); border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); font-size: .9rem; }
.icon-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.ed-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ed-preview { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--paper); max-height: 420px; overflow: auto; font-size: .92rem; }
.ed-preview .prose { font-size: .92rem; }
.ed-q { border: 1px solid var(--line-soft); background: var(--paper); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.ed-q-head { display: flex; gap: 8px; align-items: center; }
.ed-q-head select { width: auto; }
.ed-opt { display: flex; gap: 8px; align-items: center; }
.ed-opt input[type="text"] { flex: 1; }
.ed-pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.ed-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.help-box { font-size: .84rem; color: var(--ink-2); background: var(--primary-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.help-box code { background: var(--white); padding: 1px 5px; border-radius: 4px; font-size: .8rem; }

/* ---------- Footer (app pages) ---------- */
.app-foot { max-width: 1240px; margin: 0 auto; padding: 24px 20px 40px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .84rem; color: var(--ink-3); border-top: 1px solid var(--line); }
.app-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.app-foot a { color: var(--ink-2); text-decoration: none; }
.app-foot a:hover { color: var(--primary); }
a.hdr-user { text-decoration: none; }
a.hdr-user:hover { color: var(--primary); }

/* ---------- Course page: tools, time, notes ---------- */
.time-left { font-size: .8rem; color: var(--ink-3); margin: -10px 0 16px; }
.nav-meta { display: block; font-size: .74rem; color: var(--ink-3); font-weight: 400; margin-top: 1px; }
.nav-tools { padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.nav-icon { border: 0; background: var(--paper); font-size: .72rem; }
.note-box { margin-top: 28px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.note-box summary { cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: .92rem; }
.note-box textarea { display: block; width: calc(100% - 28px); margin: 0 14px 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); resize: vertical; line-height: 1.5; }
.note-box textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.note-box > .hint { display: block; padding: 0 14px 10px; min-height: 1.6em; }
.notes-list { display: grid; gap: 12px; }
.note-card { border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: var(--radius-sm); padding: 12px 16px; }
.note-card-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.note-card p { white-space: pre-wrap; color: var(--ink-2); font-size: .94rem; }
.stat-row-sm { margin-bottom: 18px; }
.stat-row-sm .stat-card { background: var(--paper); }

/* ---------- Discussions ---------- */
.post-form, .reply-form { display: grid; gap: 8px; margin-bottom: 18px; }
.reply-form { margin: 0 0 4px 46px; }
.reply-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); resize: vertical; }
.post-form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.reply-form .post-form-foot { justify-content: flex-end; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; font-size: .84rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.threads { display: grid; gap: 14px; }
.thread { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; }
.post-head { display: flex; gap: 10px; align-items: flex-start; }
.post-head > div { flex: 1; min-width: 0; }
.post-head .sub { display: block; font-size: .78rem; color: var(--ink-3); }
.sub-inline { font-size: .8rem; color: var(--ink-3); }
.avatar { flex: 0 0 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.post-tutor .avatar { background: var(--teal); color: #fff; }
.tutor-badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--teal-soft); color: var(--teal); padding: 2px 8px; border-radius: 999px; }
.post-text { white-space: pre-wrap; margin-left: 46px; font-size: .95rem; color: #2A2F45; overflow-wrap: anywhere; }
.post-reply { margin-left: 46px; padding: 12px 14px; background: var(--paper); border-radius: var(--radius-sm); }
.post-reply .post-text { margin-left: 46px; }
.post-del { font-size: .8rem; color: var(--ink-3); font-weight: 500; }
.post-del:hover { color: var(--red); }
.thread-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: 46px; }

/* ---------- Learner dashboard ---------- */
.learn-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.learn-side { display: grid; gap: 16px; }
.learn-side .panel + .panel { margin-top: 0; }
.resume-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 24px; }
.resume-card img { width: 100%; height: 100%; object-fit: cover; order: 2; min-height: 220px; }
.resume-empty { grid-template-columns: 1fr; }
.resume-body { padding: 24px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.resume-body h2 { font-size: 1.3rem; }
.resume-body .progress-bar { width: 100%; margin: 4px 0 0; }
.up-next { width: 100%; background: var(--paper); border-radius: var(--radius-sm); padding: 10px 14px; display: flex; flex-direction: column; margin-bottom: 4px; }
.tab-n { font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.goal-panel h2, .learn-side h2 { font-size: 1rem; margin-bottom: 6px; }
.goal-dots { display: flex; gap: 6px; margin: 12px 0 6px; }
.goal-dots span { flex: 1; height: 10px; border-radius: 999px; background: var(--line-soft); }
.goal-dots span.on { background: linear-gradient(90deg, var(--primary), var(--teal)); }
.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 10px; }
.side-stats.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
.side-stats div { background: var(--paper); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; }
.side-stats b { font-family: var(--font-head); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.side-stats span { font-size: .74rem; color: var(--ink-3); line-height: 1.3; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: .7rem; font-weight: 700; color: var(--ink-3); padding-bottom: 2px; }
.cal-day { aspect-ratio: 1; display: grid; place-items: center; font-size: .78rem; border-radius: 50%; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cal-day.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.cal-day.goal-met { background: var(--teal); color: #fff; font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-legend { display: flex; gap: 14px; margin-top: 10px; font-size: .74rem; color: var(--ink-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-key { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-key.active { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-key.goal-met { background: var(--teal); }
.notice { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; background: var(--primary-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.notice > div { display: flex; flex-direction: column; gap: 3px; }
.notice p { color: var(--ink-2); white-space: pre-wrap; }

/* ---------- Staff dashboard ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-grid .panel + .panel { margin-top: 0; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 18px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; }
.bar-fill { width: 100%; max-width: 34px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar:hover .bar-fill { background: var(--teal); }
.bar-val { font-size: .68rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bar em { font-style: normal; font-size: .66rem; color: var(--ink-3); height: 16px; margin-top: 4px; white-space: nowrap; }
.pill-btn { border: 0; cursor: pointer; font: inherit; font-size: .74rem; font-weight: 700; }
.pill-btn:hover { box-shadow: inset 0 0 0 1px currentColor; }
.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 64px); box-shadow: 0 20px 60px rgba(22,26,46,.25); }
.modal::backdrop { background: rgba(22,26,46,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--white); }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 18px 20px 22px; display: grid; gap: 14px; }
.detail-course { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.detail-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-course .progress-bar { margin-bottom: 6px; }
.detail-quizzes { list-style: none; padding: 0; margin: 8px 0 0; font-size: .86rem; }
.detail-quizzes li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line-soft); }
.detail-quizzes li span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.profile { max-width: 760px; }

/* ---------- Privacy policy ---------- */
.legal { max-width: 780px; margin: 0 auto; padding: 32px 20px 60px; }
.legal article { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 4vw, 44px); }
.legal h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 6px; }
.legal h2 { font-size: 1.15rem; margin: 30px 0 10px; scroll-margin-top: calc(var(--hdr) + 16px); }
.legal p, .legal li { color: #2A2F45; }
.legal p + p { margin-top: 10px; }
.legal ul { padding-inline-start: 1.2em; margin: 8px 0 0; }
.legal li + li { margin-top: 8px; }
.legal-updated { color: var(--ink-3) !important; font-size: .88rem; margin-bottom: 18px; }
.legal-toc { background: var(--paper); border-radius: var(--radius-sm); padding: 14px 18px; margin-top: 20px; font-size: .9rem; }
.legal-toc ol { margin: 0; padding-inline-start: 1.3em; columns: 2; column-gap: 24px; }
.legal-toc li + li { margin-top: 4px; }
.legal-lang { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 12px; }
.legal-lang button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink-2); }
.legal-lang button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.legal [lang="ar"] { font-family: 'Tajawal', var(--font); line-height: 1.8; }
.legal [lang="ar"] h1, .legal [lang="ar"] h2 { font-family: 'Tajawal', var(--font-head); font-weight: 700; }

@media (max-width: 980px) {
  .learn-grid { grid-template-columns: 1fr; }
  .learn-side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 640px) {
  .resume-card { grid-template-columns: 1fr; }
  .resume-card img { order: 0; min-height: 0; aspect-ratio: 16 / 9; }
  .post-text, .thread-foot, .post-reply, .reply-form, .post-reply .post-text { margin-left: 0; }
  .legal-toc ol { columns: 1; }
}

/* ---------- Admin banner + learner display preferences (set in Settings) ---------- */
.site-banner { padding: 10px 20px; text-align: center; font-size: .9rem; font-weight: 600; line-height: 1.45; }
.site-banner-info { background: #EEF0FD; color: #362CA0; }
.site-banner-warning { background: #FEF3E2; color: #7A3A06; }
html[data-text="large"] { font-size: 112.5%; }
html[data-text="xlarge"] { font-size: 125%; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
html.underline-links a { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Settings ---------- */
.hdr-settings { gap: 6px; }
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--hdr) + 20px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .92rem; }
.settings-nav a:hover { background: var(--white); color: var(--primary); }
.settings-main .panel { scroll-margin-top: calc(var(--hdr) + 16px); }
.settings-main .panel h2 { display: flex; align-items: center; gap: 8px; }
.settings-sub { font-size: .95rem; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.settings-sub:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 4px; }
.check-col { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check > span { display: flex; flex-direction: column; font-size: .94rem; }
.check input, .check-inline input { width: 18px; height: 18px; accent-color: var(--primary); flex: 0 0 auto; margin-top: 2px; }
.field-narrow { max-width: 260px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.setting-row:first-of-type { border-top: 0; padding-top: 0; }
.setting-row > div { display: flex; flex-direction: column; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) 32px; gap: 10px; align-items: center; font-size: .88rem; }
.hbars li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar { height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.hbars b { text-align: right; font-variant-numeric: tabular-nums; }
.detail-profile { background: var(--paper); border-radius: var(--radius-sm); padding: 10px 14px; display: grid; gap: 4px; font-size: .9rem; }
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-nav a { background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .84rem; }
  .setting-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) { .hdr-settings span { display: none; } .hdr-settings { padding: 7px 10px; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .course-layout { grid-template-columns: 1fr; }
  .course-nav { position: static; max-height: none; }
  .nav-toggle { display: flex; width: 100%; justify-content: space-between; margin-bottom: 10px; }
  .course-nav.collapsed .nav-modules { display: none; }
  .ed-split, .ed-grid { grid-template-columns: 1fr; }
}
.logo span, .preview-pill { white-space: nowrap; }
@media (max-width: 600px) {
  .hdr-user, .hdr-nav > a.hdr-link[href^="index.html"] { display: none; }
  .match-row { grid-template-columns: 1fr; }
  .match-fix { grid-column: 1; }
  .q-options-row { flex-direction: column; }
  .diagram-steps li:not(:last-child)::after { content: none; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  #appHeader, .no-print { display: none !important; }
  body { background: #fff; }
}
