/* =====================================================================
   منصة أشور التعليمية — design system (see docs/DESIGN.md)
   Mobile-first. Layout: bottom bar < 768px, icon rail 768–1279px, sidebar ≥ 1280px.
   ===================================================================== */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(/vendor/fonts/plex-arabic-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(/vendor/fonts/plex-arabic-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(/vendor/fonts/plex-arabic-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(/vendor/fonts/plex-arabic-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(/vendor/fonts/plex-arabic-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(/vendor/fonts/plex-arabic-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(/vendor/fonts/plex-arabic-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(/vendor/fonts/plex-arabic-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }

:root {
  --brand: #1F4E9C; --brand-600: #1A438A; --brand-700: #163A75; --brand-50: #EEF3FB; --brand-100: #DCE6F6;
  --gold: #C9A227; --gold-50: #FBF5E2; --gold-700: #8A6D12;
  --ok: #15803D; --ok-50: #E8F6EE; --warn: #B45309; --warn-50: #FDF1E4; --danger: #B91C1C; --danger-50: #FDECEC;
  --bg: #F7F8FB; --surface: #FFFFFF; --surface-2: #F1F4F9; --text: #0F172A; --muted: #5B6779; --faint: #8A95A6;
  --line: #E3E8F0; --line-strong: #CBD3DF;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .18);
  --radius: 16px; --radius-sm: 10px; --radius-xs: 8px;
  --nav-h: 64px; --rail-w: 84px; --side-w: 264px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
[data-theme="dark"] {
  --brand: #4C7FD6; --brand-600: #5B8BDD; --brand-700: #2A5BB0; --brand-50: #13213A; --brand-100: #1B2D4F;
  --gold: #D9B444; --gold-50: #2A2412; --gold-700: #E8C866;
  --ok: #3FB46B; --ok-50: #10261A; --warn: #E08A3A; --warn-50: #2A1C0E; --danger: #EF5A5A; --danger-50: #2C1414;
  --bg: #0B1220; --surface: #111A2E; --surface-2: #17223A; --text: #E5EAF3; --muted: #9AA6BA; --faint: #6D7A90;
  --line: #1F2B44; --line-strong: #2C3A57;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 6px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Plex Arabic", "Noto Kufi Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 16px; line-height: 1.65; text-rendering: optimizeLegibility;
  min-height: 100vh; min-height: 100dvh;
}
img, svg, video { display: block; max-width: 100%; }
svg[aria-hidden] { flex: none; }
.badge svg { width: 14px; height: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-100); }

/* ------------------------------------------------------------------ app shell */
.app { min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand .logo { width: 34px; height: 34px; flex: none; }
@media (min-width: 768px) { .topbar .top-brand { display: none; } }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; margin-top: -4px; }

.nav { position: fixed; z-index: 40; background: var(--surface); }
.nav a {
  display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 500;
  border-radius: 12px; transition: background-color .2s var(--ease), color .2s var(--ease);
}
.nav a svg { width: 24px; height: 24px; flex: none; }
.nav a.active { color: var(--brand); }
.nav .nav-foot { margin-top: auto; }

/* mobile: bottom tab bar */
.nav {
  inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
}
.nav .nav-head, .nav .nav-foot, .nav .nav-extra { display: none; }
.nav a { flex-direction: column; gap: 1px; font-size: .72rem; padding: 4px 2px; flex: 1 1 0; min-width: 0; justify-content: center; max-width: 96px; }
.nav a span { display: block; flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.6; }
.nav a.active { background: transparent; }
.nav a.active svg { transform: translateY(-1px); }
.main { padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1280px; margin: 0 auto; }

/* tablet: icon rail on the right */
@media (min-width: 768px) {
  .nav {
    inset: 0 0 0 auto; width: var(--rail-w); height: 100vh; height: 100dvh;
    flex-direction: column; justify-content: flex-start; gap: 6px;
    border-top: 0; border-inline-start: 1px solid var(--line); padding: 14px 10px;
  }
  .nav .nav-head { display: flex; justify-content: center; padding-bottom: 10px; }
  .nav .nav-foot { display: flex; flex-direction: column; gap: 6px; }
  .nav a { max-width: none; flex: none; font-size: .7rem; padding: 10px 4px; }
  .nav a:hover { background: var(--surface-2); color: var(--text); }
  .nav a.active { background: var(--brand-50); }
  .app.has-nav .content { margin-inline-start: var(--rail-w); }
  .main { padding: 24px 28px 48px; }
}
/* desktop: full sidebar */
@media (min-width: 1280px) {
  .nav { width: var(--side-w); padding: 18px 14px; }
  .nav .nav-head { justify-content: flex-start; padding: 0 8px 18px; }
  .nav .nav-extra { display: block; }
  .nav a { flex-direction: row; font-size: .95rem; padding: 11px 14px; gap: 14px; }
  .app.has-nav .content { margin-inline-start: var(--side-w); }
  .main { padding: 28px 40px 56px; }
}
.nav-brand-full { display: none; }
@media (min-width: 1280px) { .nav-brand-full { display: block; } }

/* ------------------------------------------------------------------ layout helpers */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > *, .stack > *, .stack-sm > * { min-width: 0; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
@media (min-width: 640px) and (max-width: 899px) { .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head p { color: var(--muted); margin-top: 2px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 -4px; }
.section-title h2 { font-size: 1.05rem; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 24px; }
.card.flush { padding: 0; overflow: hidden; }
.card.link { transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease); cursor: pointer; display: block; color: inherit; }
@media (hover: hover) { .card.link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); } }
.card.link:active { transform: scale(.99); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); margin-bottom: 6px; }
.stat .ic svg { width: 20px; height: 20px; }
.stat.gold .ic { background: var(--gold-50); color: var(--gold-700); }
.stat.ok .ic { background: var(--ok-50); color: var(--ok); }
.stat.warn .ic { background: var(--warn-50); color: var(--warn); }

.hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 22px 20px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #2A63BE 0%, var(--brand) 45%, #12305F 100%);
  box-shadow: var(--shadow);
}
[data-theme="dark"] .hero { background: radial-gradient(120% 140% at 100% 0%, #24519C 0%, #1B3D78 45%, #0E2246 100%); }
.hero::after {
  content: ""; position: absolute; inset-inline-start: -40px; bottom: -60px; width: 220px; height: 220px; opacity: .14;
  background: url(/assets/star.svg) center/contain no-repeat;
}
.hero h1 { font-size: 1.35rem; }
.hero p { opacity: .85; margin-top: 4px; }
.hero > * { position: relative; z-index: 1; }

/* course card */
.course-card { display: flex; flex-direction: column; gap: 12px; }
.course-cover {
  height: 92px; border-radius: 12px; position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 12px;
  color: #fff; font-weight: 700; font-size: 1.15rem;
}
.course-cover::before { content: ""; position: absolute; inset: 0; background: url(/assets/star.svg) no-repeat; background-size: 120px; background-position: left -20px top -30px; opacity: .18; }
.course-cover span { position: relative; text-shadow: 0 1px 8px rgba(0, 0, 0, .25); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none; user-select: none;
  transition: background-color .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
.btn:hover { background: var(--brand-600); }
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 1.05rem; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--brand-50); color: var(--brand); }
.btn.soft:hover { background: var(--brand-100); }
.btn.gold { background: var(--gold); color: #1B1B1B; }
.btn.gold:hover { filter: brightness(1.05); }
.btn.danger { background: var(--danger); }
.btn.danger.soft { background: var(--danger-50); color: var(--danger); }
.btn.white { background: #fff; color: var(--brand-700); }
.btn.icon { padding: 0; width: 44px; }
.btn.icon.sm { width: 36px; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .92rem; }
.field .hint { color: var(--muted); font-size: .82rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; background: var(--surface);
  border: 1.5px solid var(--line-strong); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.input.ltr-input { direction: ltr; text-align: right; }
.input-wrap { position: relative; }
.input-wrap .iconbtn { position: absolute; inset-inline-end: 4px; top: 4px; }
.input-wrap .input { padding-inline-end: 48px; }
.form-error { color: var(--danger); background: var(--danger-50); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 4px; }
.segmented button { border: 0; background: transparent; min-height: 40px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s; }
.segmented button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px; transition: background-color .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(-18px); }
.code-input { font-size: 1.3rem; letter-spacing: .12em; text-align: center; font-weight: 700; direction: ltr; text-transform: uppercase; }

/* ------------------------------------------------------------------ badges, chips, progress */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.gold { background: var(--gold-50); color: var(--gold-700); }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.danger { background: var(--danger-50); color: var(--danger); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.pulse .dot { animation: pulse 1.4s ease-in-out infinite; }
.chip { border: 1.5px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 8px 12px; cursor: pointer; font-weight: 600; transition: border-color .15s, background-color .15s; }
.chip:hover { border-color: var(--brand); background: var(--brand-50); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #3D74D1); border-radius: 99px; transition: width .4s var(--ease); }
.progress.gold > i { background: linear-gradient(90deg, var(--gold), #E2C258); }
.ring { --p: 0; --c: var(--brand); width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; text-align: center; line-height: 1.2; }
.ring .v { font-size: 1.6rem; font-weight: 700; }

/* ------------------------------------------------------------------ lists */
.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 60px; color: inherit; }
.list > .item:last-child { border-bottom: 0; }
.list > a.item:hover, .list > .item.clickable:hover { background: var(--surface-2); cursor: pointer; }
.item .lead { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.item .lead svg { width: 22px; height: 22px; }
.item .body { flex: 1; min-width: 0; }
.item .body .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .body .s { color: var(--muted); font-size: .85rem; }
.lead.done { background: var(--ok-50); color: var(--ok); }
.lead.locked { background: var(--surface-2); color: var(--faint); }

/* table → cards on small screens */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
@media (max-width: 767px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; }
}

/* ------------------------------------------------------------------ empty, skeleton, toast, dialog */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .art { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.empty .art svg { width: 36px; height: 36px; }
.empty h3 { color: var(--text); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 12px; }
.toasts { position: fixed; z-index: 100; inset-inline: 12px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 768px) { .toasts { bottom: 24px; inset-inline: auto 24px; inset-inline-start: auto; align-items: flex-end; } }
.toast { pointer-events: auto; max-width: 440px; background: #0F172A; color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: toast-in .3s var(--ease); }
[data-theme="dark"] .toast { background: #E5EAF3; color: #0F172A; }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok svg { color: #4ADE80; } .toast.err svg { color: #F87171; }
.toast.out { animation: toast-out .25s ease forwards; }
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(8, 12, 24, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade-in .2s ease; }
.dialog { background: var(--surface); width: 100%; max-height: 92vh; max-height: 92dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: sheet-in .32s var(--ease); }
.dialog::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 2px auto 12px; }
.dialog .d-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dialog .d-foot { display: flex; gap: 10px; margin-top: 18px; }
.dialog .d-foot .btn { flex: 1; }
@media (min-width: 768px) {
  .overlay { align-items: center; padding: 24px; }
  .dialog { max-width: 520px; border-radius: 22px; padding: 22px 24px; animation: pop-in .25s var(--ease); }
  .dialog.wide { max-width: 760px; }
  .dialog::before { display: none; }
  .dialog .d-foot { justify-content: flex-start; }
  .dialog .d-foot .btn { flex: 0 0 auto; }
}

/* ------------------------------------------------------------------ auth screens */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
.auth-side { display: none; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); max-width: 460px; width: 100%; margin: 0 auto; gap: 22px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-logo .logo { width: 72px; height: 72px; filter: drop-shadow(0 8px 18px rgba(31, 78, 156, .3)); }
@media (min-width: 1024px) {
  .auth { grid-template-columns: 1.1fr 1fr; }
  .auth-side { display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #fff; position: relative; overflow: hidden;
    background: radial-gradient(120% 120% at 100% 0%, #2A63BE 0%, var(--brand) 40%, #0F2A55 100%); }
  .auth-side .bigstar { position: absolute; width: 520px; height: 520px; inset-inline-start: -120px; bottom: -140px; opacity: .12; }
  .auth-side h2 { font-size: 2rem; line-height: 1.4; max-width: 460px; }
  .auth-side ul { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 14px; }
  .auth-side li { display: flex; gap: 12px; align-items: center; opacity: .92; }
  .auth-side li svg { width: 22px; height: 22px; color: var(--gold); }
}

/* ------------------------------------------------------------------ player */
.player { position: relative; background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 9; box-shadow: var(--shadow); }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player .wm {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; user-select: none;
  color: rgba(255, 255, 255, .55); font-weight: 700; font-size: clamp(12px, 2vw, 18px); white-space: nowrap;
  text-shadow: 0 0 3px rgba(0, 0, 0, .55); transition: transform 1.2s var(--ease); direction: rtl;
}
.player .fs-btn { position: absolute; z-index: 6; top: 10px; inset-inline-start: 10px; background: rgba(0, 0, 0, .45); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; opacity: .85; }
.player .fs-btn svg { width: 22px; height: 22px; }
.player .state { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; background: radial-gradient(circle, rgba(31, 78, 156, .35), rgba(0, 0, 0, .9)); }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
.player.pseudo-fs { position: fixed; inset: 0; z-index: 90; border-radius: 0; aspect-ratio: auto; }

/* ------------------------------------------------------------------ exam */
.exam-bar { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; direction: ltr; padding: 4px 12px; border-radius: 10px; background: var(--brand-50); color: var(--brand); }
.timer.low { background: var(--danger-50); color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.option { display: flex; align-items: center; gap: 14px; width: 100%; text-align: start; padding: 14px 16px; min-height: 60px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; transition: border-color .15s, background-color .15s, transform .1s; }
.option:hover { border-color: var(--line-strong); }
.option:active { transform: scale(.99); }
.option .letter { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; flex: none; }
.option.on { border-color: var(--brand); background: var(--brand-50); }
.option.on .letter { background: var(--brand); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-50); }
.option.correct .letter { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--danger); background: var(--danger-50); }
.option.wrong .letter { background: var(--danger); color: #fff; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; }
.palette button { height: 42px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--surface); font-weight: 700; cursor: pointer; }
.palette button.answered { background: var(--brand); border-color: var(--brand); color: #fff; }
.palette button.current { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 60%, transparent); }

/* ------------------------------------------------------------------ calendar */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav b { flex: 1; text-align: center; font-size: .95rem; }
@media (max-width: 599px) { .hide-sm { display: none !important; } }
.cal { display: grid; grid-template-columns: 52px repeat(7, minmax(110px, 1fr)); overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.cal .hcell { position: sticky; top: 0; background: var(--surface-2); padding: 8px 6px; text-align: center; font-size: .82rem; font-weight: 600; border-bottom: 1px solid var(--line); z-index: 2; }
.cal .hcell.today { color: var(--brand); }
.cal .times { position: relative; }
.cal .times div { height: 48px; font-size: .72rem; color: var(--faint); text-align: center; padding-top: 2px; border-bottom: 1px dashed var(--line); }
.cal .day { position: relative; border-inline-start: 1px solid var(--line); }
.cal .day .slot { height: 48px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.cal .day .slot:hover { background: var(--brand-50); }
.cal .ev { position: absolute; inset-inline: 4px; border-radius: 10px; padding: 4px 8px; font-size: .76rem; overflow: hidden; z-index: 1; line-height: 1.35; }
.cal .ev.own { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.cal .ev.other { background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 6px, var(--line) 6px, var(--line) 12px); color: var(--muted); border: 1px solid var(--line-strong); }
.cal .ev.buffer { background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--warn) 45%, transparent); z-index: 0; }

/* ------------------------------------------------------------------ misc */
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.kbd { font-family: ui-monospace, "SF Mono", Menlo, monospace; direction: ltr; display: inline-block; background: var(--surface-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 8px; font-weight: 600; letter-spacing: .04em; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: var(--surface); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.upload-box { border: 2px dashed var(--line-strong); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background-color .15s; }
.upload-box:hover, .upload-box.drag { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--gold-50); color: var(--text); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.notice svg { width: 22px; height: 22px; flex: none; color: var(--gold-700); margin-top: 2px; }
.notice.info { background: var(--brand-50); border-color: var(--brand-100); }
.notice.info svg { color: var(--brand); }
.notice.danger { background: var(--danger-50); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.danger svg { color: var(--danger); }
.splash { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.splash .logo { width: 84px; height: 84px; animation: breathe 1.6s ease-in-out infinite; }
.view-enter { animation: view-in .28s var(--ease); }
.print-sheet { display: none; }
.print-sheet h1 { font-size: 14pt; margin: 0 0 4mm; }
.print-codes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.print-codes div { border: 1px dashed #555; border-radius: 3mm; padding: 4mm; text-align: center; font-size: 9pt; color: #222; break-inside: avoid; }
.print-codes b { display: block; font: 700 13pt ui-monospace, monospace; letter-spacing: .06em; direction: ltr; margin: 2mm 0; color: #000; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } }
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(16px); opacity: 0; } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media print {
  body.printing > :not(.print-sheet) { display: none !important; }
  body.printing .print-sheet { display: block; margin: 10mm; }
  .nav, .topbar, .toasts, .no-print { display: none !important; }
  .app.has-nav .content { margin: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
