:root {
  --brand: #F6921E;          /* colorBlueOne in the app */
  --brand-dark: #d97a0c;
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --field: #cfdcf6;          /* login field colour from the app */
  --ok: #16a34a;
  --bad: #dc2626;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9rem; }
.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- buttons ---------- */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; background: #eee; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #d1d5db; color: #6b7280; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 6px 14px; font-size: .9rem; }
.icon-btn { background: transparent; border: 0; font-size: 1.4rem; padding: 4px 10px; color: #fff; }
.chip { background: rgba(255,255,255,.22); border: 0; color: #fff; border-radius: 999px; padding: 6px 12px; font-size: .85rem; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  background: var(--brand); color: #fff; padding: 10px 12px; min-height: 56px;
}
.topbar h1 { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-logo { width: 38px; height: 38px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.topbar-logo img { width: 30px; height: 30px; }
.topbar-actions { display: flex; gap: 6px; }
.timer { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: #e8b65a url('/assets/login_bg.jpg') center / cover no-repeat;
}
.login-card { width: 100%; max-width: 400px; }
.login-logo {
  width: 200px; height: 200px; margin: 0 auto 36px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.login-logo img { width: 150px; }
.id-box, .field {
  width: 100%; background: var(--field); border: 1.5px solid #374151; border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.05rem; color: var(--ink);
}
.id-box { text-align: center; font-size: 1.2rem; margin-bottom: 10px; }
.id-box.error { color: var(--bad); }
.field::placeholder { color: #6b7280; }
.field:focus { outline: 3px solid rgba(246,146,30,.6); outline-offset: 1px; }
#loginForm { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; width: auto; }
.field-icon {
  flex: 0 0 56px; display: flex; align-items: center; justify-content: center;
  background: var(--field); border: 1.5px solid #374151; border-radius: var(--radius);
}
.field-icon img { width: 30px; height: 30px; object-fit: contain; mix-blend-mode: multiply; }
.lang-row { display: flex; justify-content: center; gap: 28px; margin: 8px 0; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.lang-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.lang-row img { height: 20px; }
.lang-row input { accent-color: var(--brand); width: 18px; height: 18px; }
select.field { appearance: auto; }

/* ---------- home ---------- */
.profile { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand); flex: none; }
.avatar-empty { background: #e5e7eb; }
.profile-name { font-weight: 700; font-size: 1.1rem; }
.pill { display: inline-block; margin-top: 4px; background: #fff3e3; color: var(--brand-dark); border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 150px; background: var(--card); border: 0; border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 700; font-size: 1.05rem;
}
.tile:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.tile-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.5rem; }

.intro { background: #fff3e3; border-inline-start: 4px solid var(--brand); padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- video list ---------- */
.video-card {
  display: flex; gap: 12px; width: 100%; text-align: start; background: var(--card); border: 0;
  border-radius: var(--radius); padding: 10px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.video-card.locked { opacity: .4; }
.thumb { position: relative; flex: 0 0 132px; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #111; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.6rem; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.video-body { flex: 1; min-width: 0; }
.video-title { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.video-desc { color: var(--muted); font-size: .9rem; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: #fff3e3; color: var(--brand-dark); }
.badge.done { background: #dcfce7; color: var(--ok); }
.badge.fail { background: #fee2e2; color: var(--bad); }

/* ---------- player ---------- */
.player-page { position: fixed; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; }
.player-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.player-top span { flex: 1; font-weight: 600; }
.player-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.player-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.big-play { position: absolute; width: 80px; height: 80px; border-radius: 50%; border: 0; background: rgba(246,146,30,.9); color: #fff; font-size: 2rem; }
.player-controls { display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); font-variant-numeric: tabular-nums; font-size: .9rem; }
.player-controls input { flex: 1; accent-color: var(--brand); }

/* ---------- exam list ---------- */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.exam-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px;
  background: var(--card); border: 0; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08); text-align: center;
}
.exam-tile.locked { opacity: .4; }
.exam-tile.final { grid-column: 1 / -1; }
.exam-num { width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.4rem; font-weight: 800; }
.exam-name { font-weight: 700; }
.exam-rem { font-size: .8rem; color: var(--brand-dark); font-weight: 600; }

/* ---------- exam ---------- */
.exam-meta { display: flex; justify-content: space-between; padding-bottom: 0; font-weight: 600; color: var(--muted); }
.q-image { background: var(--card); border-radius: var(--radius); padding: 10px; text-align: center; }
.q-image img { max-height: 260px; object-fit: contain; }
.q-title { font-size: 1.1rem; margin: 16px 0 12px; }
.options { display: flex; flex-direction: column; gap: 10px; padding-bottom: 90px; }
.option { text-align: start; background: var(--card); border: 1.5px solid var(--brand); border-radius: 12px; padding: 14px 16px; font-size: 1rem; }
.option.selected { background: var(--brand); color: #fff; }
.exam-footer { position: fixed; bottom: 0; inset-inline: 0; background: var(--bg); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
.exam-footer .btn { max-width: 728px; margin: 0 auto; }
.step-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding-bottom: 90px; }
.step-item { position: relative; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); padding: 6px; }
.step-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.step-badge { position: absolute; top: 6px; inset-inline-start: 6px; background: var(--brand); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: .8rem; font-weight: 700; }
.step-preview { display: block; max-height: 180px; margin: 0 auto 10px; }

/* ---------- result ---------- */
.result-summary { border-radius: var(--radius); padding: 16px; text-align: center; color: #fff; margin-bottom: 14px; }
.result-summary.pass { background: var(--ok); }
.result-summary.fail { background: var(--bad); }
.result-status { font-size: 1.4rem; font-weight: 800; }
.report-item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.report-img { width: 84px; height: 84px; object-fit: contain; flex: none; }
.report-body { flex: 1; min-width: 0; font-size: .95rem; }
.report-q { font-weight: 600; margin-bottom: 4px; }
.report-mark { width: 28px; height: 28px; flex: none; }
.txt-ok { color: var(--ok); font-weight: 600; }
.txt-bad { color: var(--bad); font-weight: 600; }
.result-img { display: block; max-width: 220px; margin: 0 auto; border-radius: 10px; }

/* ---------- modal / loader / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 420px; max-height: 90vh; overflow: auto; }
.modal-msg { margin: 0 0 16px; font-size: 1.02rem; text-align: center; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.modal-actions .btn { flex: 1 1 auto; min-width: 90px; }
.loader { position: fixed; inset: 0; background: rgba(255,255,255,.7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 60; font-weight: 600; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(246,146,30,.25); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.light { position: absolute; border-color: rgba(255,255,255,.25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 70; max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 420px) {
  .thumb { flex-basis: 108px; }
  .tile { min-height: 130px; }
}
