/* QuizHub — design system */
:root {
  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f5f6fb;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, .08), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, .07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f3f4fa;
  --surface-3: #eceef7;
  --border: #e6e8f2;
  --border-strong: #d6d9e8;
  --text: #0f1222;
  --text-2: #3b4060;
  --muted: #6b7194;
  --primary: #6246ea;
  --primary-2: #8b5cf6;
  --primary-ink: #ffffff;
  --primary-soft: #efebff;
  --primary-ring: rgba(98, 70, 234, .18);
  --grad: linear-gradient(135deg, #6246ea 0%, #8b5cf6 55%, #c084fc 100%);
  --green: #12a150; --green-soft: #e3f7ec;
  --red: #e5484d; --red-soft: #feeceb;
  --amber: #c27803; --amber-soft: #fff4dc;
  --blue: #2f6fed; --blue-soft: #e7efff;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(15, 18, 34, .04);
  --shadow: 0 1px 2px rgba(15, 18, 34, .04), 0 4px 16px -4px rgba(15, 18, 34, .06);
  --shadow-lg: 0 24px 60px -12px rgba(15, 18, 34, .25);
  --sidebar: 264px;
  color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0b0c14;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, .14), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, .06), transparent 60%);
    --surface: #13151f; --surface-2: #1a1d2a; --surface-3: #222636;
    --border: #252938; --border-strong: #31364a;
    --text: #eef0fa; --text-2: #c4c8de; --muted: #8b91ad;
    --primary: #8b7bff; --primary-2: #a78bfa; --primary-ink: #ffffff; --primary-soft: #221f3d; --primary-ring: rgba(139, 123, 255, .25);
    --green: #3ddc84; --green-soft: #12291d; --red: #ff6b6f; --red-soft: #321719; --amber: #f5b83d; --amber-soft: #30250d; --blue: #6ea2ff; --blue-soft: #15223d;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.02) inset; --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6);
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 var(--font); background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed; color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.02em; font-weight: 750; }
h1 { font-size: 1.85rem; letter-spacing: -.03em; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; } h4 { font-size: .92rem; }
p { margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; }
::selection { background: var(--primary-ring); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pre { white-space: pre-wrap; }

/* ---------------------------------------------------------------- app layout */
.app-layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.25rem 1rem; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(18px);
  border-inline-end: 1px solid var(--border); overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 800; font-size: 1.2rem; color: var(--text); letter-spacing: -.03em; padding: .25rem .5rem; }
.brand:hover { text-decoration: none; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 1rem; font-weight: 800; box-shadow: 0 6px 16px -4px rgba(98, 70, 234, .55); flex-shrink: 0; }
.side-label { font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 0 .75rem; margin-bottom: .4rem; display: flex; justify-content: space-between; align-items: center; }
.side-label button { padding: 0 .4rem; border: 0; background: none; color: var(--muted); font-size: 1.05rem; line-height: 1; }
.side-label button:hover { color: var(--primary); background: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .92rem; transition: background .15s, color .15s; }
.side-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.side-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side-nav a.active { background: var(--primary-soft); color: var(--primary); }
.side-nav a.active svg { opacity: 1; }
.side-hub { display: flex; align-items: center; gap: .65rem; padding: .45rem .75rem; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .88rem; }
.side-hub:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.side-hub.active { background: var(--primary-soft); color: var(--primary); }
.side-hub .hub-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: .7rem; font-weight: 800; flex-shrink: 0; }
.side-hub span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: .65rem; padding: .75rem; border-radius: 14px; background: var(--surface-2); }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who strong { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who span { display: block; font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 10px; display: grid; place-items: center; background: transparent; border: 1px solid transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.mobile-bar { display: none; }
.main-wrap { min-width: 0; }
main { max-width: 1180px; margin: 0 auto; padding: 2.25rem 2.5rem 5rem; animation: rise .35s ease both; }
@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; width: 280px; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); background: var(--surface); }
  .app-layout.nav-open .sidebar { transform: none; }
  .app-layout.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8, 10, 20, .45); z-index: 30; }
  .mobile-bar { display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 20; padding: .7rem 1rem; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
  main { padding: 1.5rem 1rem 4rem; }
}

/* ---------------------------------------------------------------- generic layout */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem; }
.page-head p { margin: 0; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .5rem; font-weight: 500; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1.1rem; }
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
.grid-main { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.spacer { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 1rem; }
.card-link { display: block; color: inherit; transition: transform .2s ease, box-shadow .2s ease, border-color .2s; }
.card-link:hover { text-decoration: none; transform: translateY(-3px); box-shadow: 0 18px 40px -16px rgba(40, 30, 120, .28); border-color: var(--border-strong); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 2.25rem 0 .9rem; }
.section-title h2, .section-title h3 { margin: 0; }
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--muted); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.empty h2, .empty h3 { color: var(--text); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin: 0 auto 1rem; font-size: 1.5rem; }
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1.5rem; }
.stat { padding: 1.1rem 1.25rem; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat .value { font-size: 1.75rem; font-weight: 800; margin-top: .25rem; letter-spacing: -.03em; }
.stat::after { content: ""; position: absolute; right: -26px; bottom: -26px; width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); opacity: .8; pointer-events: none; }
.stat .label, .stat .value { position: relative; z-index: 1; }

/* hero (dashboard) */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 2rem 2.1rem; color: #fff; background: var(--grad); box-shadow: 0 24px 50px -20px rgba(98, 70, 234, .6); margin-bottom: 1.75rem; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero::before { width: 320px; height: 320px; right: -80px; top: -140px; }
.hero::after { width: 200px; height: 200px; right: 160px; bottom: -120px; background: rgba(255, 255, 255, .08); }
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; font-size: 2rem; margin-bottom: .35rem; }
.hero p { color: rgba(255, 255, 255, .85); margin: 0; }
.hero .hero-stats { display: flex; gap: 2.25rem; margin-top: 1.5rem; flex-wrap: wrap; }
.hero .hero-stats div { font-size: .78rem; color: rgba(255, 255, 255, .75); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero .hero-stats strong { display: block; font-size: 1.7rem; color: #fff; letter-spacing: -.02em; text-transform: none; }
.hero .btn-hero { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(6px); }
.hero .btn-hero:hover { background: rgba(255, 255, 255, .26); }
.hero .btn-hero.solid { background: #fff; color: var(--primary); border-color: #fff; }
.hero .btn-hero.solid:hover { background: #f5f3ff; }

/* hub cover */
.hub-card { padding: 0; overflow: hidden; }
.hub-card .cover { height: 92px; position: relative; padding: 1rem 1.2rem; display: flex; align-items: flex-start; justify-content: space-between; }
.hub-card .cover::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 0%, rgba(255,255,255,.35), transparent 50%); }
.hub-card .cover .badge { position: relative; z-index: 1; background: rgba(255, 255, 255, .22); color: #fff; backdrop-filter: blur(6px); }
.hub-card .hub-initial { position: absolute; inset-inline-start: 1.2rem; bottom: -22px; z-index: 2; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; color: #fff; border: 3px solid var(--surface); font-size: 1rem; }
.hub-card .body { padding: 1.9rem 1.2rem 1.2rem; }
.hub-card h3 { margin: 0 0 .25rem; }
.hub-card .desc { color: var(--muted); font-size: .86rem; margin: 0 0 1rem; min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hub-card .foot { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); font-weight: 600; border-top: 1px solid var(--border); padding-top: .85rem; }
.hub-banner { border-radius: 22px; padding: 1.9rem 2rem; color: #fff; position: relative; overflow: hidden; margin-bottom: 1.25rem; }
.hub-banner::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 90% -20%, rgba(255,255,255,.35), transparent 45%), radial-gradient(circle at 0% 120%, rgba(0,0,0,.18), transparent 50%); pointer-events: none; }
.hub-banner > * { position: relative; z-index: 1; }
.hub-banner .crumbs, .hub-banner .crumbs a { color: rgba(255, 255, 255, .8); }
.hub-banner h1 { color: #fff; margin-bottom: .3rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.hub-banner p { color: rgba(255, 255, 255, .88); margin: 0; max-width: 720px; }
.hub-banner .badge { background: rgba(255, 255, 255, .22); color: #fff; }
.hub-banner .btn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .3); color: #fff; }
.hub-banner .btn:hover { background: rgba(255, 255, 255, .26); }
.hub-banner .btn-primary { background: #fff; color: #1d1840; border-color: #fff; }
.hub-banner .btn-primary:hover { background: #f4f2ff; filter: none; }

/* ---------------------------------------------------------------- buttons & forms */
button, .btn {
  font: inherit; font-weight: 650; font-size: .88rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.05rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s, filter .15s; box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); border-color: transparent; color: var(--primary-ink); box-shadow: 0 6px 16px -6px rgba(98, 70, 234, .6); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.07) saturate(1.05); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .36rem .7rem; font-size: .8rem; border-radius: 9px; }
.btn-lg { padding: .85rem 1.6rem; font-size: 1rem; border-radius: 13px; }
label { display: block; font-weight: 650; font-size: .84rem; margin-bottom: .4rem; color: var(--text-2); }
.field { margin-bottom: 1.1rem; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .35rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=search], textarea, select {
  width: 100%; font: inherit; font-size: .92rem; padding: .62rem .85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select { appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7194' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border-strong)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.check { display: flex; align-items: flex-start; gap: .65rem; font-weight: 600; cursor: pointer; margin-bottom: .75rem; color: var(--text); font-size: .9rem; }
.check input { margin-top: .2rem; accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; }
.check .hint { font-weight: 500; margin-top: .1rem; }
.inline-form { display: flex; gap: .6rem; }
.inline-form input, .inline-form select { flex: 1; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .7rem; font-weight: 750; padding: .22rem .6rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; vertical-align: middle; line-height: 1.4; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.purple { background: var(--primary-soft); color: var(--primary); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 8%, transparent); } }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .85rem 1.15rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 750; background: var(--surface-2); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
tr.me td { background: var(--primary-soft); }
.table-wrap { overflow-x: auto; }
.rank { font-weight: 800; width: 3.5rem; font-size: 1.05rem; }
.rank-1, .rank-2, .rank-3 { font-size: 1.3rem; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: inline-flex; gap: .25rem; padding: .3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; margin-bottom: 1.75rem; overflow-x: auto; max-width: 100%; }
.tabs a { padding: .5rem 1rem; color: var(--muted); font-weight: 650; font-size: .88rem; border-radius: 9px; white-space: nowrap; transition: background .15s, color .15s; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(15, 18, 34, .1); }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); color: inherit; transition: background .12s; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
a.list-item:hover .chev { transform: translateX(3px); color: var(--primary); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.list-item .meta { font-size: .8rem; color: var(--muted); margin-top: .15rem; font-weight: 500; }
.chev { color: var(--muted); transition: transform .15s, color .15s; flex-shrink: 0; }
.exam-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.1rem; }
.exam-icon.open { background: var(--green-soft); color: var(--green); }
.exam-icon.scheduled { background: var(--blue-soft); color: var(--blue); }
.exam-icon.closed { background: var(--primary-soft); color: var(--primary); }
.exam-icon.draft { background: var(--surface-3); color: var(--muted); }
.exam-icon svg { width: 20px; height: 20px; }
.score-pill { font-weight: 800; font-size: .95rem; padding: .3rem .7rem; border-radius: 10px; background: var(--surface-2); }

/* ---------------------------------------------------------------- progress & charts */
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .6s ease; }
.bar.green > span { background: linear-gradient(90deg, #12a150, #34d399); } .bar.red > span { background: linear-gradient(90deg, #e5484d, #fb7185); } .bar.amber > span { background: linear-gradient(90deg, #c27803, #fbbf24); }
.histogram { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: .5rem; }
.histogram .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.histogram .col .b { width: 100%; background: var(--grad); border-radius: 7px 7px 3px 3px; min-height: 3px; }
.histogram .col .n { font-size: .72rem; color: var(--text-2); font-weight: 700; }
.histogram .col .l { font-size: .68rem; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- editor */
.q-edit { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.15rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.q-edit:focus-within { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: 0 0 0 4px var(--primary-ring); }
.q-edit .q-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.q-edit .q-num { font-weight: 800; color: #fff; background: var(--grad); border-radius: 9px; padding: .2rem .55rem; font-size: .8rem; }
.q-edit .q-head select { width: auto; padding-top: .35rem; padding-bottom: .35rem; font-size: .84rem; font-weight: 600; }
.opt-row { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.opt-row input[type=text] { flex: 1; }
.opt-row .opt-letter { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 750; color: var(--muted); font-size: .8rem; flex-shrink: 0; }
.opt-row input[type=radio], .opt-row input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--green); flex-shrink: 0; cursor: pointer; }
.add-bar { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; align-items: center; padding: 1.1rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.sticky-bar { position: sticky; bottom: 1rem; margin-top: 1.5rem; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 16px; padding: .8rem 1rem; display: flex; gap: .65rem; justify-content: flex-end; align-items: center; z-index: 10; box-shadow: var(--shadow-lg); }

/* ---------------------------------------------------------------- exam taking */
.take-top { position: sticky; top: 0; z-index: 15; margin: -2.25rem -2.5rem 1.75rem; padding: 1rem 2.5rem; background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1.25rem; }
.take-top .t-title { flex: 1; min-width: 0; }
.take-top .t-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.take-top .progress { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: .45rem; max-width: 420px; }
.take-top .progress span { display: block; height: 100%; background: var(--grad); transition: width .3s ease; }
@media (max-width: 960px) { .take-top { margin: -1.5rem -1rem 1.25rem; padding: .8rem 1rem; top: 57px; } }
.timer-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .9rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.timer-chip.warn { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); animation: pulse 1s infinite; }
.take-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .take-layout { grid-template-columns: 1fr; } .take-side { display: none; } }
.take-side { position: sticky; top: 100px; }
.qnav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.qnav a { display: grid; place-items: center; height: 36px; border-radius: 10px; border: 1px solid var(--border-strong); color: var(--muted); font-weight: 750; font-size: .82rem; transition: all .12s; }
.qnav a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.qnav a.done { background: var(--grad); color: #fff; border-color: transparent; }
.qnav a.flag { box-shadow: 0 0 0 2px var(--amber); }
.legend { display: flex; gap: .9rem; font-size: .74rem; color: var(--muted); margin-top: .85rem; font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.q-card { scroll-margin-top: 110px; padding: 1.6rem; }
.q-card .q-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .8rem; font-weight: 650; margin-bottom: .75rem; gap: .5rem; }
.q-card .q-num-chip { display: inline-flex; align-items: center; gap: .5rem; }
.q-card .q-num-chip b { background: var(--primary-soft); color: var(--primary); border-radius: 8px; padding: .15rem .5rem; font-size: .78rem; }
.q-card .q-prompt { font-size: 1.12rem; font-weight: 650; margin-bottom: 1.15rem; white-space: pre-wrap; line-height: 1.5; letter-spacing: -.01em; }
.choice { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border: 1.5px solid var(--border); border-radius: 13px; margin-bottom: .6rem; cursor: pointer; font-weight: 550; transition: border-color .12s, background .12s, transform .1s; background: var(--surface); }
.choice:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.choice:active { transform: scale(.995); }
.choice input { accent-color: var(--primary); width: 19px; height: 19px; margin: 0; flex-shrink: 0; }
.choice .letter { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 750; font-size: .8rem; color: var(--muted); flex-shrink: 0; transition: all .12s; }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); }
.choice.selected .letter { background: var(--primary); color: #fff; }
.choice.correct { border-color: var(--green); background: var(--green-soft); }
.choice.correct .letter { background: var(--green); color: #fff; }
.choice.wrong { border-color: var(--red); background: var(--red-soft); }
.choice.wrong .letter { background: var(--red); color: #fff; }
.choice .tag { margin-inline-start: auto; font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.review-q { position: relative; padding-inline-start: 1.6rem; }
.review-q::before { content: ""; position: absolute; inset-inline-start: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; }
.review-q.correct::before { background: var(--green); }
.review-q.wrong::before { background: var(--red); }
.explain { background: var(--surface-2); border-radius: 12px; padding: .85rem 1rem; font-size: .9rem; margin-top: .9rem; border: 1px solid var(--border); }

/* ---------------------------------------------------------------- result */
.score-hero { display: flex; align-items: center; gap: 2.25rem; flex-wrap: wrap; }
.ring { --p: 0; --c: var(--primary); width: 156px; height: 156px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); flex-shrink: 0; animation: ring-in .8s ease both; }
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
@keyframes ring-in { from { --p: 0; } }
.ring > div { width: 124px; height: 124px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring .pct { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.metric { min-width: 90px; }
.metric .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.metric .v { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.podium .card { text-align: center; padding: 1.4rem 1rem; }
.podium .first { padding: 2rem 1rem; border: 1.5px solid #e9c46a; background: linear-gradient(180deg, color-mix(in srgb, #f6d365 18%, var(--surface)), var(--surface)); }
.podium .medal { font-size: 2rem; line-height: 1; margin-bottom: .5rem; }
.podium .first .medal { font-size: 2.6rem; }

/* ---------------------------------------------------------------- auth */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { position: relative; overflow: hidden; background: var(--grad); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art::before { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: rgba(255, 255, 255, .1); right: -160px; top: -160px; }
.auth-art::after { content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%; background: rgba(255, 255, 255, .07); left: -120px; bottom: -140px; }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { color: #fff; padding: 0; }
.auth-art .brand .logo { background: rgba(255, 255, 255, .2); box-shadow: none; backdrop-filter: blur(6px); }
.auth-art h2 { font-size: 2.4rem; line-height: 1.12; color: #fff; letter-spacing: -.035em; max-width: 480px; margin-bottom: 1rem; }
.auth-art p { color: rgba(255, 255, 255, .85); max-width: 440px; font-size: 1.02rem; }
.auth-feats { display: grid; gap: .8rem; margin-top: 2rem; max-width: 440px; }
.auth-feats div { display: flex; gap: .8rem; align-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px; padding: .8rem 1rem; backdrop-filter: blur(6px); font-weight: 600; font-size: .92rem; }
.auth-feats span { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; flex-shrink: 0; }
.auth-form-side { display: grid; place-items: center; padding: 2.5rem 1.5rem; }
.auth-card { width: 100%; max-width: 400px; animation: rise .4s ease both; }
.auth-card h1 { font-size: 1.85rem; }
.auth-card .mobile-brand { display: none; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .auth-split { grid-template-columns: 1fr; } .auth-art { display: none; } .auth-card .mobile-brand { display: flex; } }

/* ---------------------------------------------------------------- modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(8, 10, 22, .5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 1rem; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; padding: 1.75rem; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { max-width: 840px; }
.modal h2 { margin-bottom: .6rem; }
.modal .actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; }
.modal .tabs { display: flex; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 1.25rem; inset-inline-end: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { display: flex; align-items: center; gap: .6rem; background: #14162a; color: #fff; padding: .8rem 1.1rem; border-radius: 13px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); animation: toast-in .25s cubic-bezier(.2, .9, .3, 1.2); max-width: 380px; }
.toast::before { content: "✓"; width: 22px; height: 22px; border-radius: 50%; background: var(--green); display: grid; place-items: center; font-size: .75rem; flex-shrink: 0; }
.toast.error { background: #3a1416; }
.toast.error::before { content: "!"; background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* ---------------------------------------------------------------- misc */
.code-box { display: flex; align-items: center; gap: .75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: .8rem 1rem; }
.code-box .code { font-family: ui-monospace, monospace; font-size: 1.5rem; font-weight: 800; letter-spacing: .16em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
pre.block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; overflow-x: auto; font-size: .8rem; white-space: pre-wrap; word-break: break-all; margin: .5rem 0 1rem; }
.loading { padding: 5rem 1rem; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.announcement { padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); }
.announcement:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.3rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem 1.5rem; }
.kv div span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: .15rem; }
.kv div strong { font-weight: 650; font-size: .92rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; margin: 1.25rem 0; }
.info-grid > div { background: var(--surface-2); border-radius: 12px; padding: .75rem .9rem; }
.info-grid span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.info-grid strong { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; }
.vis-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.vis-list li { display: flex; gap: .7rem; font-size: .87rem; color: var(--text-2); align-items: flex-start; }
.vis-list li span { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; font-size: .85rem; }
.chev svg { width: 18px; height: 18px; display: block; }
.choice input[hidden] { display: none; }
#tab > .section-title:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- RTL / Arabic */
.lang-btn { font-weight: 800; font-size: .9rem; font-family: "IBM Plex Sans Arabic", var(--font); }
.lang-pill { font-family: "IBM Plex Sans Arabic", var(--font); }
.auth-form-side { position: relative; }
.auth-form-side > .lang-corner { position: absolute; top: 1.25rem; inset-inline-end: 1.25rem; }
[dir=rtl] body { font-family: "IBM Plex Sans Arabic", "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif; font-size: 15.5px; }
[dir=rtl] *, [dir=rtl] *::before, [dir=rtl] *::after { letter-spacing: 0 !important; }
[dir=rtl] h1, [dir=rtl] h2, [dir=rtl] h3 { font-weight: 700; line-height: 1.35; }
[dir=rtl] .badge, [dir=rtl] th, [dir=rtl] .stat .label, [dir=rtl] .side-label, [dir=rtl] .metric .k, [dir=rtl] .info-grid span, [dir=rtl] .kv div span, [dir=rtl] .hero .hero-stats div { text-transform: none; font-size: .78rem; }
[dir=rtl] select { background-position: left .8rem center; padding-right: .85rem; padding-left: 2.2rem; }
[dir=rtl] .chev svg { transform: scaleX(-1); }
[dir=rtl] a.list-item:hover .chev { transform: translateX(-3px); }
[dir=rtl] .review-q::before { border-radius: 4px 0 0 4px; }
[dir=rtl] .hero::before { right: auto; left: -80px; }
[dir=rtl] .hero::after { right: auto; left: 160px; }
[dir=rtl] .auth-art::before { right: auto; left: -160px; }
[dir=rtl] .auth-art::after { left: auto; right: -120px; }
[dir=rtl] .stat::after { right: auto; left: -26px; }
[dir=rtl] .side-nav a svg[data-flip], [dir=rtl] .icon-btn#logout svg { transform: scaleX(-1); }
[dir=rtl] input[type=email], [dir=rtl] input[name=code], [dir=rtl] .mono, [dir=rtl] .code-box, [dir=rtl] pre.block { direction: ltr; text-align: left; }
[dir=rtl] .timer-chip { direction: ltr; }
@media (max-width: 960px) { [dir=rtl] .sidebar { transform: translateX(102%); } [dir=rtl] .app-layout.nav-open .sidebar { transform: none; } }
/* Let user-written content follow its own direction (Arabic questions in the English UI and vice versa) */
.q-prompt, .opt-text, .explain, .pre, .q-edit textarea, .q-edit input[type=text], #imp-text, #e-title, #e-desc, textarea[name=body] { unicode-bidi: plaintext; text-align: start; }

/* theme switching */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after { transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease !important; }
[data-theme-toggle] svg { transition: transform .4s ease; }
[data-theme-toggle]:hover svg { transform: rotate(20deg); }
.seg { display: inline-flex; gap: .25rem; padding: .3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; box-shadow: none; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 18, 34, .12); }
.seg button svg { width: 16px; height: 16px; }
.side-tools { margin-top: auto; display: flex; gap: .35rem; padding: 0 .35rem; }
.side-tools .icon-btn { border-color: var(--border); background: var(--surface); }
.side-tools .icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.side-tools + .side-foot { margin-top: 0; }
.connect-box { border: 1.5px solid color-mix(in srgb, var(--primary) 35%, var(--border)); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); border-radius: 14px; padding: 1rem 1.1rem; }
.steps { margin: 0 0 .75rem; padding-inline-start: 1.2rem; font-size: .9rem; display: grid; gap: .55rem; }
