/* مصمم مثاني — one look for every page: the colours of the institution's mark on warm ivory. */
@font-face { font-family: 'Plex Arabic'; src: url('/fonts/plex-regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('/fonts/plex-medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('/fonts/plex-bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Hafs'; src: url('/fonts/hafs.ttf') format('truetype'); font-display: swap; }

:root {
  /* the two colours of the mark */
  --olive: #6a5c35;
  --gold: #9c8445;
  --gold-light: #c9ae6a;
  --ivory: #fbf8f1;
  --paper: #f5efe3;

  --bg: #f7f2e8;
  --surface: #fffdf8;
  --surface-2: #f6f0e3;
  --ink: #2a2418;
  --ink-soft: #4b4230;
  --muted: #7d735f;
  --line: #e6dcc8;
  --line-strong: #d6c8aa;
  --brand: var(--olive);
  --brand-ink: #fffaf0;
  --accent: var(--gold);
  --accent-soft: #f3ead3;
  --ok: #2f6f4a;
  --ok-soft: #e3f0e6;
  --warn: #8a5f12;
  --warn-soft: #f9efd8;
  --bad: #9d3a2f;
  --bad-soft: #f7e3df;
  --shadow-sm: 0 1px 2px rgba(64, 50, 20, .06);
  --shadow: 0 1px 2px rgba(64, 50, 20, .05), 0 10px 30px -12px rgba(64, 50, 20, .18);
  --shadow-lg: 0 24px 60px -20px rgba(54, 42, 15, .35);
  --radius: 20px;
  --radius-sm: 14px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  /* one family everywhere: IBM Plex Sans Arabic (the face of the unified government design system) */
  --display: 'Plex Arabic', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120c;
    --surface: #1d1912;
    --surface-2: #241f16;
    --ink: #f1eadb;
    --ink-soft: #d9cfbb;
    --muted: #a99f8a;
    --line: #342d20;
    --line-strong: #463d2b;
    --brand: #c9ae6a;
    --brand-ink: #1a160e;
    --accent: #d4b872;
    --accent-soft: #2c2516;
    --ok: #79c495;
    --ok-soft: #17291e;
    --warn: #e2b55c;
    --warn-soft: #2e2613;
    --bad: #ec8a7d;
    --bad-soft: #351b17;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 'Plex Arabic', system-ui, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[hidden] { display: none !important; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0; line-height: 1.35; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ buttons and fields */
.btn { appearance: none; border: 1px solid transparent; border-radius: 999px; padding: 11px 20px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; text-decoration: none; cursor: pointer; background: var(--surface-2); color: var(--ink); transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s, opacity .18s; -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, #7b6a3e, #5f5131); color: #fffaf0; box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 8px 20px -10px rgba(74, 61, 28, .8); }
.btn.primary:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 12px 26px -10px rgba(74, 61, 28, .9); }
@media (prefers-color-scheme: dark) { .btn.primary { background: linear-gradient(180deg, #d6bd7c, #b99b55); color: #1a160e; box-shadow: 0 8px 22px -12px rgba(0, 0, 0, .9); } }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--accent-soft); color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; }
.icon-btn { appearance: none; border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link { appearance: none; border: 0; background: none; padding: 4px 6px; color: var(--brand); cursor: pointer; font-weight: 500; }
.link.danger { color: var(--bad); }

.field { display: grid; gap: 8px; }
.field > span { font-weight: 600; font-size: 15px; color: var(--ink-soft); }
input, select, textarea { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; font-size: 16px; }
textarea { min-height: 0; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%239c8445' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-position: 14px 50%; background-size: 18px 18px; background-repeat: no-repeat; padding-left: 42px; text-overflow: ellipsis; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.error { color: var(--bad); min-height: 1.4em; margin: 0; font-size: 14px; text-align: center; }
.note { margin: 0; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ the mark with its light */
.mark-shine { position: relative; display: inline-block; line-height: 0; }
.mark-shine img { display: block; width: auto; }
.mark-shine .shine { position: absolute; inset: 0; pointer-events: none; -webkit-mask: url('/brand/symbol') center / contain no-repeat; mask: url('/brand/symbol') center / contain no-repeat; background: linear-gradient(112deg, transparent 0 38%, rgba(255, 246, 214, .95) 48%, rgba(255, 255, 255, .55) 52%, transparent 62% 100%); background-size: 260% 100%; background-position: 130% 0; mix-blend-mode: screen; animation: shine 5.5s var(--ease) 1.2s infinite; }
.mark-shine.big img { height: clamp(120px, 20vh, 170px); }
.mark-shine.huge img { height: clamp(170px, 34vh, 280px); }
@keyframes shine { 0% { background-position: 130% 0; } 45%, 100% { background-position: -30% 0; } }

/* ------------------------------------------------------------ the entrance */
.stage, .welcome { position: fixed; inset: 0; display: grid; place-items: center; overflow: auto; background: radial-gradient(120% 80% at 50% 30%, #fffdf7 0%, #f8f2e4 45%, #eee3cb 100%); color: #2a2418; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.stage-light { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(40% 30% at 50% 28%, rgba(233, 201, 138, .32), transparent 70%); animation: breathe 7s ease-in-out infinite alternate; }
@keyframes breathe { from { opacity: .65; transform: scale(1); } to { opacity: 1; transform: scale(1.06); } }
.stage-inner { position: relative; width: min(400px, 100%); display: grid; justify-items: center; text-align: center; animation: rise .9s var(--ease) both; }
.stage-title { margin: 18px 0 0; font-size: clamp(28px, 6vw, 34px); color: #3f3520; }
.stage-sub { margin: 2px 0 26px; color: #8a7d5f; font-size: 15px; }
.login-card { width: 100%; display: grid; gap: 16px; padding: 24px 22px 18px; border-radius: 24px; background: rgba(255, 253, 248, .78); border: 1px solid rgba(214, 200, 170, .8); box-shadow: 0 30px 60px -30px rgba(84, 66, 24, .45), 0 1px 0 rgba(255, 255, 255, .9) inset; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); text-align: start; }
.login-card .field > span { color: #5a4e33; }
.login-card input { background: #fffdf8; border-color: #ddd0b3; color: #2a2418; }
.login-card .btn.primary { background: linear-gradient(180deg, #7b6a3e, #5f5131); color: #fffaf0; margin-top: 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.welcome { z-index: 60; transition: opacity .7s var(--ease), transform .9s var(--ease); }
.welcome.leaving { opacity: 0; transform: scale(1.03); pointer-events: none; }
.welcome-inner { position: relative; display: grid; justify-items: center; text-align: center; }
.welcome .mark-shine { animation: arrive 1.3s var(--ease) both; }
.welcome .mark-shine .shine { animation: shine 2.2s var(--ease) .55s 1 both; }
.welcome-hello { margin: 26px 0 0; font-family: var(--display); font-size: clamp(26px, 6vw, 36px); font-weight: 700; color: #3f3520; animation: rise .8s var(--ease) .65s both; }
.welcome-rule { display: block; width: 72px; height: 2px; margin: 14px 0 12px; border-radius: 2px; background: linear-gradient(90deg, transparent, #b8994e, transparent); animation: grow .9s var(--ease) .9s both; }
.welcome-sub { margin: 0; color: #8a7d5f; font-size: 16px; animation: rise .8s var(--ease) 1s both; }
@keyframes arrive { from { opacity: 0; transform: scale(.9); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes grow { from { transform: scaleX(0); opacity: 0; } to { transform: none; opacity: 1; } }
#shell.entering { animation: reveal .8s var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ inner pages */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { height: 44px; width: auto; }
@media (prefers-color-scheme: dark) { .brand-mark { filter: brightness(0) invert(1); opacity: .92; } }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text b { font-family: var(--display); font-size: 20px; font-weight: 700; }
.brand-text small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbar { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 14px; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 22px 16px calc(80px + env(safe-area-inset-bottom)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-head h2 { margin: 0; font-size: 22px; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.compose { display: grid; gap: 20px; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { appearance: none; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 8px 15px; min-height: 40px; font-size: 14.5px; font-weight: 500; cursor: pointer; color: var(--ink-soft); transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.choice:hover { border-color: var(--accent); }
.choice[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--brand); box-shadow: 0 0 0 1px var(--accent) inset; font-weight: 600; }

.drop { border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, var(--line)); border-radius: var(--radius); padding: 28px 16px; text-align: center; display: grid; gap: 6px; justify-items: center; cursor: pointer; background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent); transition: background .2s, border-color .2s, transform .2s var(--ease); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.over { transform: scale(1.01); }
.drop strong { font-size: 17px; font-weight: 600; }
.drop-sub { color: var(--muted); font-size: 13.5px; }
.drop-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: var(--brand); background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--line); margin-bottom: 4px; }

.picked { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.picked:empty { display: none; }
.picked li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.picked .meta { min-width: 0; }
.picked .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.picked .sub { font-size: 13px; color: var(--muted); }
.picked input { min-height: 40px; padding: 8px 12px; font-size: 14px; margin-top: 8px; }
.picked .bar { grid-column: 1 / -1; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.block { margin-top: 34px; }
.section-title { font-size: 19px; margin: 0 2px 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head .section-title { margin: 0; }
.search { flex: 0 1 320px; }
.search input { min-height: 42px; padding: 8px 14px; border-radius: 999px; }
.list { display: grid; gap: 12px; }

.job { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.job-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.job-title { font-weight: 700; font-size: 16.5px; }
.job-sub { color: var(--muted); font-size: 13.5px; }
.status { font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-light), var(--gold), var(--olive)); border-radius: inherit; transition: width .5s var(--ease); }
.bar.indeterminate > i { width: 32%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-inline-start: -32%; } 100% { margin-inline-start: 100%; } }
.steps { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin: 0; padding: 0; list-style: none; }
.steps li { display: inline-flex; align-items: center; gap: 6px; }
.steps li::before { content: ''; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.steps li.done { color: var(--ok); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--brand); background: var(--accent-soft); border-radius: 999px; padding: 2px 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: grid; }
.tile .poster { position: relative; aspect-ratio: 9 / 16; background: #000; cursor: pointer; border: 0; padding: 0; display: block; width: 100%; }
.tile .poster img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease); }
.tile .poster:hover img { transform: scale(1.03); }
.tile .poster::after { content: ''; position: absolute; inset: auto 12px 12px auto; width: 46px; height: 46px; border-radius: 50%; background: rgba(20, 16, 8, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8 5.5v13a1 1 0 0 0 1.5.86l10.4-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5Z'/%3E%3C/svg%3E") center / 20px no-repeat; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tile .info { padding: 12px 14px 14px; display: grid; gap: 8px; }
.tile .title { font-weight: 700; line-height: 1.45; }
.tile .sub { color: var(--muted); font-size: 13px; }
.tile .row-actions > * { flex: 1; }

.archive { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.arow { display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.arow:last-child { border-bottom: 0; }
.arow img, .arow .ph { width: 54px; height: 96px; object-fit: cover; border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.arow .t { font-weight: 600; }
.arow .s { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.arow .row-actions { justify-content: flex-end; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
#more { margin-top: 12px; }

.toast { position: fixed; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom)); margin: 0 auto; max-width: 520px; background: #2b2417; color: #fbf3df; padding: 14px 18px; border-radius: 16px; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .45); transform: translateY(calc(100% + 40px)); opacity: 0; visibility: hidden; transition: transform .35s var(--ease), opacity .35s, visibility .35s; z-index: 80; font-weight: 500; text-align: center; }
.toast.show { transform: none; opacity: 1; visibility: visible; }

dialog { border: 0; border-radius: 22px; padding: 0; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow-lg); }
dialog[open] { animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(18, 14, 6, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.wide-dialog { width: min(840px, calc(100vw - 24px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h3 { margin: 0; font-size: 17px; }
#video { display: block; width: 100%; max-height: 68dvh; background: #000; }
.dialog-actions { display: grid; gap: 10px; padding: 14px 18px 18px; }
.dialog-actions .row-actions > * { flex: 1; }

#reviewbody { padding: 16px 18px 20px; display: grid; gap: 14px; }
.review-media video, .review-media audio { width: 100%; border-radius: 14px; background: #000; }
.review-media video { max-height: 52dvh; }
.ayat { display: grid; gap: 10px; }
.ayah { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; background: var(--surface); }
.ayah.flag { border-color: var(--warn); background: var(--warn-soft); }
.ayah .ref { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ayah .text { font-family: 'Hafs', serif; font-size: 26px; line-height: 2.1; text-align: center; }
.notice { padding: 11px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.correct-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; align-items: end; margin-top: 10px; }
.correct-form .btn { grid-column: 1 / -1; }
details summary { cursor: pointer; font-weight: 600; color: var(--brand); }
label { display: grid; gap: 6px; font-weight: 500; }

@media (max-width: 600px) {
  .wrap { padding-inline: 12px; }
  .card { padding: 18px 16px; border-radius: 18px; }
  .brand-mark { height: 38px; }
  .brand-text small { display: none; }
  .who { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .info { padding: 10px; }
  .tile .row-actions { flex-direction: column; }
  .tile .row-actions > * { width: 100%; }
  .arow { grid-template-columns: 48px 1fr; gap: 12px; }
  .arow img, .arow .ph { width: 48px; height: 86px; }
  .arow .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .correct-form { grid-template-columns: 1fr 1fr; }
  .correct-form label:first-child { grid-column: 1 / -1; }
  .search { flex: 1 1 100%; }
  .choice { padding: 7px 12px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
