:root {
  --bg: #f3f8fd;
  --surface: #ffffff;
  --surface-2: #ecf4fb;
  --text: #132235;
  --muted: #5a6b7d;
  --border: #dbe7f2;
  --primary: #0277b6;
  --primary-600: #075985;
  --primary-50: #e0f2fe;
  --accent: #c2410c;
  --accent-50: #fff1e8;
  --success: #16a34a;
  --success-50: #e9f8ee;
  --warning: #b45309;
  --warning-50: #fef5e7;
  --danger: #dc2626;
  --danger-50: #fdecec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.18);
  /* solid fill behind white text (buttons); equals --primary in light mode */
  --primary-solid: var(--primary);
  --accent-solid: var(--accent);
  --success-solid: var(--success);
  --danger-solid: var(--danger);
  --toast-bg: #132235;
  --footer-bg: #0b2a45;
  --hero-bg: linear-gradient(120deg, #fff4ea 0%, #f3efff 45%, #e3f2fe 100%);
  /* notebook home: highlighter, graph-paper lines, margin rule */
  --hl: #ffe45c;
  --hl-solid: #ffd21f;
  --hl-text: #1b2440;
  --paper-line: #deebf7;
  --margin-line: rgba(229, 72, 77, 0.5);
  color-scheme: light;
}

/* Dark theme: an explicit choice wins, otherwise follow the device setting. */
:root[data-theme='dark'] {
  --bg: #07121f;
  --surface: #0f1e30;
  --surface-2: #15283f;
  --text: #e4eef8;
  --muted: #9db0c4;
  --border: #22374f;
  --primary: #7dd3fc;
  --primary-600: #38bdf8;
  --primary-50: rgba(125, 211, 252, 0.14);
  --primary-solid: #0277b6;
  --accent-solid: #c2410c;
  --success-solid: #16a34a;
  --danger-solid: #dc2626;
  --accent: #fb923c;
  --accent-50: rgba(251, 146, 60, 0.14);
  --success: #4ade80;
  --success-50: rgba(74, 222, 128, 0.14);
  --warning: #fbbf24;
  --warning-50: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-50: rgba(248, 113, 113, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --toast-bg: #22374f;
  --footer-bg: #050d17;
  --hero-bg: linear-gradient(120deg, #1b2236 0%, #18233d 45%, #10273f 100%);
  --hl: rgba(250, 204, 21, 0.38);
  --hl-solid: #facc15;
  --paper-line: rgba(125, 211, 252, 0.06);
  --margin-line: rgba(248, 113, 113, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #07121f;
    --surface: #0f1e30;
    --surface-2: #15283f;
    --text: #e4eef8;
    --muted: #9db0c4;
    --border: #22374f;
    --primary: #7dd3fc;
    --primary-600: #38bdf8;
    --primary-50: rgba(125, 211, 252, 0.14);
    --primary-solid: #0277b6;
    --accent-solid: #c2410c;
    --success-solid: #16a34a;
    --danger-solid: #dc2626;
    --accent: #fb923c;
    --accent-50: rgba(251, 146, 60, 0.14);
    --success: #4ade80;
    --success-50: rgba(74, 222, 128, 0.14);
    --warning: #fbbf24;
    --warning-50: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-50: rgba(248, 113, 113, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --toast-bg: #22374f;
    --footer-bg: #050d17;
    --hero-bg: linear-gradient(120deg, #1b2236 0%, #18233d 45%, #10273f 100%);
    --hl: rgba(250, 204, 21, 0.38);
    --hl-solid: #facc15;
    --paper-line: rgba(125, 211, 252, 0.06);
    --margin-line: rgba(248, 113, 113, 0.35);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
h4 {
  line-height: 1.35;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 1.8rem;
  font-weight: 800;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  padding-top: 28px;
  padding-bottom: 60px;
  min-height: 70vh;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.pre {
  white-space: pre-wrap;
}

/* ---------- navbar ---------- */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.navbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Marhey', 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  display: block;
  overflow: hidden;
  /* same tile as public/favicon.svg */
  background: linear-gradient(135deg, #38bdf8, #0369a1);
  box-shadow: 0 2px 8px rgba(3, 105, 161, 0.25);
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav a,
.nav button.linklike {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-family: inherit;
  font-size: inherit;
  /* "My students" stays on one line instead of breaking into two */
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  color: var(--primary);
  background: var(--primary-50);
}

.nav .spacer {
  flex: 1;
}

.nav a.btn-primary,
.nav a.btn-primary:hover {
  color: #fff;
  background: var(--primary-solid);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-user-name {
  max-width: 150px;
  unicode-bidi: plaintext;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* desktop but tight (English labels are longer): the avatar alone stands for the account */
@media (min-width: 1061px) and (max-width: 1440px) {
  .navbar-inner {
    gap: 12px;
  }
  .nav a {
    padding: 8px 9px;
  }
  .nav-user-name {
    display: none;
  }
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.nav-toggle {
  display: none;
  margin-inline-start: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  padding: 4px 10px;
  cursor: pointer;
}

@media (max-width: 1060px) {
  .nav-toggle {
    display: block;
  }
  .nav {
    display: none;
    position: absolute;
    top: 64px;
    inset-inline: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px 16px;
  }
  .nav.open {
    display: flex;
  }
  .nav .spacer {
    display: none;
  }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-solid);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-600);
}

.btn-accent {
  background: var(--accent-solid);
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger-50);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-solid);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--primary);
  background: var(--primary-50);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.card + .card {
  margin-top: 18px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.stack > * + * {
  margin-top: 14px;
}

/* ---------- hero ---------- */
.hero {
  border-radius: 20px;
  padding: 40px 32px;
  margin-bottom: 28px;
  color: #fff;
  background: radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.18), transparent 40%),
    linear-gradient(135deg, var(--primary-solid), #7c3aed 55%, var(--accent-solid));
}

.hero h1 {
  font-size: 2.1rem;
}

.hero p {
  max-width: 640px;
  opacity: 0.92;
  margin: 0 0 18px;
}

.hero .btn-outline {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.hero .btn-primary {
  background: #fff;
  color: var(--primary-solid);
}

/* ---------- filters ---------- */
.filters {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 820px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .filters .search {
    grid-column: 1 / -1;
  }
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
}

/* ---------- course card ---------- */
.course-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.course-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.thumb {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2.6rem;
  font-weight: 800;
}

.course-card .body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.course-card h3 {
  margin: 0;
}

.course-card .meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- badges ---------- */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.badge-primary {
  background: var(--primary-50);
  color: var(--primary);
}

.badge-accent {
  background: var(--accent-50);
  color: var(--accent);
}

.badge-success {
  background: var(--success-50);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-50);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-50);
  color: var(--danger);
}

/* ---------- forms ---------- */
.form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='url'],
input[type='tel'],
input[type='search'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.segmented label {
  margin: 0;
  padding: 6px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
}

.segmented input {
  display: none;
}

.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.thumb-picker {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 640px) {
  .thumb-picker {
    grid-template-columns: 1fr;
  }
}

.field .thumb-drop {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  margin: 0;
}

.field .thumb-drop:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.thumb-drop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- sign in / sign up: form + illustration ---------- */
.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: stretch;
  max-width: 1080px;
  margin: -8px auto 0;
}

.auth-form {
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  padding: 4px 0;
}

.auth-form .form {
  gap: 12px;
}

.auth-form .form-row {
  gap: 12px;
}

.auth-form h1 {
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  margin: 0 0 2px;
}

.auth-form > .muted {
  margin: 0 0 16px;
}

/* an Arabic placeholder in a left-to-right field reads in the page direction until typing starts */
.auth-form input[type='password']:placeholder-shown {
  direction: inherit;
}

/* a hint under a row of two fields */
.auth-hint {
  margin-top: -6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-form .field label {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.auth-form input:not([type='checkbox']),
.auth-form select {
  padding: 10px 13px;
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-form input:not([type='checkbox']):focus,
.auth-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  line-height: 1.6;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary-solid);
  cursor: pointer;
}

.auth-submit {
  margin-top: 2px;
  padding: 12px 18px;
  font-size: 1rem;
  border-radius: 10px;
  box-shadow: 0 8px 20px -8px var(--primary-solid);
}

.auth-switch {
  margin: 14px 0 0;
  text-align: center;
  color: var(--muted);
}

.auth-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 32px;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--primary-50), var(--surface-2));
  text-align: center;
}

.auth-art .hero-illustration {
  max-width: 380px;
  max-height: 280px;
  margin-bottom: 12px;
}

.auth-art h2 {
  margin: 0;
  font-size: 1.5rem;
}

.auth-art p {
  margin: 0;
  max-width: 380px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 900px) {
  .auth-split {
    grid-template-columns: 1fr;
  }
  .auth-art {
    display: none;
  }
}

/* ---------- terms & privacy ---------- */
.legal {
  max-width: 760px;
  margin: 8px auto;
  padding: 28px clamp(20px, 4vw, 40px);
  line-height: 1.8;
}

.legal h3 {
  margin: 22px 0 6px;
}

.legal ul {
  margin: 0;
  padding-inline-start: 22px;
}

.legal-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tabs a {
  padding: 10px 16px;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabs a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: start;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: none;
}

/* ---------- lists ---------- */
.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.lesson-list li + li {
  border-top: 1px solid var(--border);
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: inherit;
}

a.lesson-item:hover {
  background: var(--surface-2);
}

.lesson-item.current {
  background: var(--primary-50);
}

.lesson-item.locked {
  color: var(--muted);
}

.lesson-num {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.85rem;
}

.lesson-num.done {
  background: var(--success-solid);
  color: #fff;
}

.lesson-item .title {
  flex: 1;
  font-weight: 600;
}

/* ---------- course header ---------- */
.course-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.course-hero .thumb {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (max-width: 820px) {
  .course-hero {
    grid-template-columns: 1fr;
  }
}

/* ---------- progress ---------- */
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: inherit;
  transition: width 0.3s;
}

/* ---------- video ---------- */
.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0b0f19;
  border-radius: var(--radius);
  overflow: hidden;
}

.video-frame iframe,
.video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-frame:fullscreen {
  border-radius: 0;
}

/* the student's name + phone drifting over the video (ui.js videoPlayer) */
.video-wm {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.25);
  font-size: clamp(11px, 1.6vw, 16px);
  font-weight: 600;
  white-space: nowrap;
  direction: ltr;
  transition: top 1.2s ease, left 1.2s ease;
}

.video-fs {
  position: absolute;
  z-index: 3;
  top: 8px;
  inset-inline-end: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.7;
}

.video-fs:hover {
  opacity: 1;
}

.video-block + .video-block {
  margin-top: 22px;
}

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat .value {
  font-size: 1.9rem;
  font-weight: 800;
}

.stat .label {
  color: var(--muted);
  font-weight: 600;
}

/* ---------- misc ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty .icon {
  font-size: 2.4rem;
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--warning-50);
  color: var(--warning);
  font-weight: 600;
}

.notice.info {
  background: var(--primary-50);
  color: var(--primary);
}
.loader {
  display: grid;
  place-items: center;
  padding: 60px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--primary-50);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.breadcrumb {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  background: var(--toast-bg);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  font-weight: 600;
  animation: slide-in 0.2s ease-out;
}

.toast.error {
  background: var(--danger-solid);
}

.toast.success {
  background: var(--success-solid);
}

@keyframes slide-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
}

.field label.check {
  display: inline-flex;
  font-weight: 600;
  margin: 0;
}

/* ---------- home sections ---------- */
.section {
  margin-top: 34px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.15s, border-color 0.15s;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.tile-icon {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--primary-50);
}

.tile-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.avatar-md {
  width: 48px;
  height: 48px;
  flex: none;
  font-size: 1.2rem;
}

.avatar-lg {
  width: 84px;
  height: 84px;
  flex: none;
  font-size: 2.2rem;
}

.grid:has(> .tile-teacher) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 18px;
}

.tile-teacher {
  gap: 20px;
  padding: 24px 22px;
}

.tile-teacher .avatar-md {
  width: 96px;
  height: 96px;
  font-size: 2.4rem;
}

.tile-teacher strong {
  font-size: 1.2rem;
}

.tile-teacher .tile-body {
  gap: 8px;
}

.tile-teacher .badge {
  font-size: 0.85rem;
  padding: 3px 12px;
}

.teacher-hero {
  display: flex;
  align-items: center;
  gap: 20px;
}

.teacher-hero h1 {
  margin: 0 0 4px;
}

.hero-compact {
  padding: 28px 32px;
}

.hero-compact h1 {
  font-size: 1.7rem;
}

.hero-search {
  display: flex;
  gap: 8px;
  max-width: 560px;
}

.hero-search input {
  flex: 1;
  border: none;
  padding: 12px 16px;
}

/* ---------- hero with illustration ---------- */
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding-block: 28px;
}

.hero-kicker {
  display: inline-block;
  padding: 4px 14px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 700;
  font-size: 0.9rem;
}

.hero-illustration {
  display: block;
  width: 100%;
  height: auto;
  max-height: 380px;
  font-family: inherit;
}

.hero-compact .hero-illustration {
  max-height: 240px;
}

.float-a,
.float-b {
  animation: hero-float 6s ease-in-out infinite;
}

.float-b {
  animation-duration: 7s;
  animation-delay: -2s;
}

@keyframes hero-float {
  50% {
    transform: translateY(-10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .float-a,
  .float-b {
    animation: none;
  }
}

@media (max-width: 860px) {
  .hero-split {
    grid-template-columns: 1fr;
  }
  .hero-art {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
  }
  .hero-compact .hero-art {
    display: none;
  }
}

/* SVG text is positioned in LTR coordinates even on RTL pages */
.hero-illustration {
  direction: ltr;
}

/* ---------- colored category tiles ---------- */
.tile-cat {
  --tint: hsl(var(--hue) 80% 55%);
  position: relative;
  overflow: hidden;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(145deg, hsl(var(--hue) 85% 55% / 0.14), var(--surface) 70%);
  border-color: hsl(var(--hue) 70% 55% / 0.3);
}

.tile-cat::after {
  content: '';
  position: absolute;
  inset-inline-end: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: hsl(var(--hue) 85% 55% / 0.12);
  transition: transform 0.25s;
}

.tile-cat:hover {
  transform: translateY(-4px);
  border-color: var(--tint);
  box-shadow: 0 12px 28px hsl(var(--hue) 70% 40% / 0.22);
}

.tile-cat:hover::after {
  transform: scale(1.35);
}

.tile-cat .tile-icon {
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  border-radius: 16px;
  background: hsl(var(--hue) 85% 55% / 0.2);
}

.tile-cat strong {
  font-size: 1.05rem;
}

/* ---------- course card thumbnail ---------- */
.thumb-wrap {
  position: relative;
  overflow: hidden;
}

.thumb-wrap .thumb {
  display: grid;
  transition: transform 0.35s ease;
}

.course-card:hover .thumb-wrap .thumb {
  transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
  .thumb-wrap .thumb,
  .tile-cat::after {
    transition: none;
  }
}

/* ---------- home: notebook ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body.is-home {
  background-color: var(--bg);
  background-image: linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 28px 28px;
}

.nb-home {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 64px;
  padding-block: 24px 16px;
}

/* the red margin rule of a notebook page */
.nb-home::before {
  content: '';
  position: absolute;
  inset-block: -40px 0;
  inset-inline-start: -28px;
  width: 2px;
  background: var(--margin-line);
  pointer-events: none;
}

.nb-home mark {
  color: inherit;
  background: linear-gradient(transparent 55%, var(--hl) 55%, var(--hl) 92%, transparent 92%);
  padding-inline: 4px;
}

.nb-kicker {
  color: var(--danger);
  font-weight: 700;
}

.nb-title {
  margin: 0;
  font-family: 'Marhey', 'Cairo', sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.9rem);
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}

.nb-lead {
  margin: 0;
  max-width: 560px;
  font-size: 1.15rem;
  line-height: 1.9;
  color: var(--muted);
}

.nb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  padding: 7px;
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--primary);
}

.nb-search label {
  display: flex;
  padding-inline: 8px 2px;
  color: var(--muted);
}

.nb-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.05rem;
  padding: 10px 4px;
}

.nb-search input:focus {
  outline: none;
  box-shadow: none;
}

.nb-search:focus-within {
  box-shadow: 4px 4px 0 var(--primary), 0 0 0 4px var(--primary-50);
}

.nb-search button {
  font: inherit;
  font-weight: 700;
  padding: 10px 24px;
  border: 0;
  border-radius: 10px;
  background: var(--hl-solid);
  color: var(--hl-text);
  cursor: pointer;
}

.nb-search button:hover {
  filter: brightness(0.95);
}

.nb-section {
  display: flex;
  flex-direction: column;
}

.nb-h2 {
  margin: 0 0 18px;
  font-family: 'Marhey', 'Cairo', sans-serif;
  font-size: 1.9rem;
}

/* notebook divider tabs */
.nb-tabs {
  display: flex;
  align-items: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
  padding-top: 4px;
}

.nb-tabs button {
  flex: none;
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border: 2px solid transparent;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: color-mix(in srgb, hsl(var(--hue) 85% 60%) 30%, var(--surface));
  color: var(--text);
  cursor: pointer;
}

.nb-tabs button:hover {
  padding-bottom: 13px;
}

.nb-tabs button[aria-selected='true'] {
  position: relative;
  z-index: 1;
  padding: 13px 18px 15px;
  margin-bottom: -2px;
  font-weight: 800;
  background: var(--hl-solid);
  color: var(--hl-text);
  border-color: var(--text);
}

.nb-sheet {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: 0 16px 16px 16px;
}

[dir='ltr'] .nb-sheet {
  border-radius: 16px 0 16px 16px;
}

.nb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.nb-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  color: var(--text);
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  transition: transform 0.15s, border-color 0.15s;
}

.nb-card:hover {
  border-color: var(--primary);
  transform: rotate(-0.6deg);
}

/* cover photo, bleeding to the card's edges */
.nb-thumb {
  display: block;
  margin: -20px -20px 4px;
  overflow: hidden;
  border-radius: 11px 11px 0 0;
  background: var(--primary-50);
}

.nb-thumb .thumb {
  display: grid;
  transition: transform 0.35s ease;
}

.nb-card:hover .nb-thumb .thumb {
  transform: scale(1.05);
}

.nb-tag {
  align-self: flex-start;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, hsl(var(--hue) 85% 60%) 25%, var(--surface));
}

.nb-card h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.6;
}

.nb-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nb-card-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

.nb-card-foot strong {
  flex: none;
  color: var(--primary);
}

.nb-more {
  align-self: flex-end;
  font-weight: 700;
}

.nb-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 36px;
}

.nb-features h3 {
  margin: 0 0 8px;
  font-family: 'Marhey', 'Cairo', sans-serif;
  font-size: 1.3rem;
  color: var(--primary);
}

.nb-features p {
  margin: 0;
  color: var(--muted);
}

/* "mobile app coming soon" banner */
.nb-app {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 44px 24px 0;
  text-align: center;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--hero-bg);
  box-shadow: var(--shadow);
}

.nb-app .nb-h2 {
  margin: 0;
  font-size: 2.1rem;
}

.nb-app p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
}

.nb-app-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 14px;
  border-radius: 999px;
  color: var(--hl-text);
  background: var(--hl-solid);
}

/* store buttons: labels only until the app ships */
.nb-app-stores {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.nb-app-store {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-radius: 12px;
  background: #0b1626;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  line-height: 1.3;
  text-align: start;
}

.nb-app-store small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.75;
}

/* a phone drawn in CSS, showing a tiny lesson screen; its lower half is cropped by the banner */
.nb-app-phone {
  width: 170px;
  margin: 14px 0 -150px;
  padding: 9px;
  border-radius: 30px;
  background: #0b1626;
  box-shadow: var(--shadow-lg);
}

.nb-app-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: 300px;
  padding: 22px 12px 12px;
  border-radius: 22px;
  background: #fff;
}

.nb-app-screen::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  translate: -50%;
  width: 44px;
  height: 6px;
  border-radius: 999px;
  background: #0b1626;
}

.nb-app-video {
  display: grid;
  place-items: center;
  height: 86px;
  border-radius: 12px;
  color: #fff;
  font-size: 1.4rem;
  background: linear-gradient(135deg, #0277b6, #7c3aed);
}

.nb-app-screen i {
  height: 9px;
  border-radius: 999px;
  background: #dbe7f2;
}

.nb-app-screen i:last-child {
  width: 60%;
}

@media (max-width: 1280px) {
  .nb-home::before {
    display: none;
  }
}

@media (max-width: 860px) {
  .nb-home {
    gap: 44px;
  }
  .nb-sheet {
    padding: 18px;
  }
  .nb-features {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .nb-app .nb-h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .nb-search button {
    padding-inline: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nb-card,
  .nb-thumb .thumb {
    transition: none;
  }
}

/* hero: a full-width banner, text on one side and the illustration on the other */
.zk-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 44px clamp(24px, 5vw, 64px);
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--hero-bg);
  box-shadow: var(--shadow);
}

.zk-hero-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.zk-hero .nb-kicker {
  color: var(--primary);
}

.zk-hero .nb-title {
  font-size: clamp(2rem, 4.2vw, 3.3rem);
}

.zk-hero mark {
  color: var(--hl-text);
  background: var(--hl-solid);
  border-radius: 10px;
  padding: 0 12px;
}

.zk-hero-art {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  justify-self: center;
  /* the legs fade out instead of stopping at the edge */
  -webkit-mask-image: linear-gradient(to bottom, #000 86%, transparent);
  mask-image: linear-gradient(to bottom, #000 86%, transparent);
}

@media (max-width: 860px) {
  .zk-hero {
    grid-template-columns: 1fr;
    padding: 30px 20px 10px;
    border-radius: 20px;
  }
  .zk-hero-art {
    max-width: 380px;
  }
}

/* ---------- footer ---------- */
.footer {
  margin-top: 40px;
  background: var(--footer-bg);
  color: #bde3f7;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 32px;
  padding-top: 44px;
  padding-bottom: 36px;
}

.footer .brand {
  color: #fff;
}

.footer-about p {
  margin: 14px 0 0;
  max-width: 360px;
  line-height: 1.9;
}

.footer h4 {
  color: #fff;
  font-size: 1rem;
  margin: 0 0 12px;
}

.footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.footer a {
  color: #bde3f7;
}

.footer a:hover {
  color: #fff;
}

.footer-bottom {
  border-top: 1px solid rgba(189, 227, 247, 0.15);
  padding: 16px 0;
  font-size: 0.85rem;
  color: #8cc4e6;
}

@media (max-width: 820px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-about {
    grid-column: 1 / -1;
  }
}

/* ---------- theme toggle ---------- */
.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.15rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.2s;
}

.lang-toggle {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
}

.lang-toggle:hover {
  transform: none;
}

.theme-toggle:hover {
  border-color: var(--primary);
  transform: rotate(-15deg);
}

/* ---------- notifications (admin bell) ---------- */
.notif {
  position: relative;
  flex: none;
}

.notif-btn {
  position: relative;
  font-size: 1.05rem;
}

.notif-btn:hover {
  transform: none;
}

.notif-count {
  position: absolute;
  top: -5px;
  inset-inline-end: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger-solid);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 30;
}

.notif.open .notif-panel {
  display: block;
  animation: fade-in 0.15s ease-out;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.notif-list {
  max-height: min(420px, 60vh);
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.notif-item:last-child {
  border-bottom: 0;
}

.notif-item:hover {
  background: var(--surface-2);
}

.notif-item.unread {
  background: var(--primary-50);
}

.notif-icon {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 1.05rem;
}

.notif-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  line-height: 1.5;
}

.notif-item.unread .notif-body > :first-child {
  font-weight: 700;
}

.notif-item.unread::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
}

.notif-list > .loader {
  padding: 28px;
}

.notif-all {
  display: block;
  padding: 11px 16px;
  text-align: center;
  font-weight: 700;
  border-top: 1px solid var(--border);
}

.notif-page {
  padding: 0;
  overflow: hidden;
}

@media (max-width: 640px) {
  .notif-panel {
    position: fixed;
    top: 72px;
    inset-inline: 16px;
    width: auto;
  }
}

body,
.navbar,
.card,
.course-card,
.tile,
.footer {
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

/* ---------- avatars & profile ---------- */
img.avatar {
  object-fit: cover;
  padding: 0;
  display: block;
}

.avatar-xs {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  display: inline-grid;
  vertical-align: middle;
}

.avatar-xl {
  width: 128px;
  height: 128px;
  font-size: 3.2rem;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
}

.teacher-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

a.user-cell {
  color: inherit;
  text-decoration: none;
}

a.user-cell:hover strong {
  color: var(--primary);
}

.mini-thumb {
  flex: none;
  width: 72px;
  border-radius: 8px;
  overflow: hidden;
}

.mini-thumb .thumb {
  font-size: 1.2rem;
}

.profile-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
}

.profile-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-photo {
  position: relative;
  width: 128px;
  height: 128px;
}

.profile-photo.busy {
  opacity: 0.5;
  pointer-events: none;
}

.photo-field {
  display: flex;
  align-items: center;
  gap: 14px;
}

.photo-field input {
  flex: 1;
  min-width: 0;
}

.photo-btn {
  position: absolute;
  bottom: 4px;
  inset-inline-start: 4px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-solid);
  color: #fff;
  border: 3px solid var(--surface);
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s;
}

.photo-btn:hover {
  transform: scale(1.08);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
}

.profile-stats .stat {
  padding: 12px;
  text-align: center;
  box-shadow: none;
}

.profile-stats .value {
  font-size: 1.3rem;
}

.profile-stats .label {
  font-size: 0.8rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.profile-grid .card + .card {
  margin-top: 0;
}

@media (max-width: 900px) {
  .profile-head {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .profile-info .btn-row {
    justify-content: center;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.filters-3 {
  grid-template-columns: 2fr 1fr 1fr;
}

.footer-grid-compact {
  grid-template-columns: 2fr 1fr 1fr;
}

@media (max-width: 820px) {
  .filters-3 {
    grid-template-columns: 1fr 1fr;
  }
  .footer-grid-compact {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- quizzes ---------- */

.question-card {
  display: grid;
  gap: 12px;
}

.question-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.question-head h3 {
  margin: 0;
  flex: 1;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-row input[type='text'] {
  flex: 1;
}

.option-row input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  flex: none;
}

.choices {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-50);
}

.choice input {
  accent-color: var(--primary);
}

.choice.correct {
  border-color: var(--success);
  background: var(--success-50);
}

.choice.wrong {
  border-color: var(--danger);
  background: var(--danger-50);
}

.choice.static {
  cursor: default;
}

.choice .mark {
  margin-inline-start: auto;
  font-weight: 700;
}

.quiz-timer {
  position: sticky;
  top: 72px;
  z-index: 5;
  align-self: start;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quiz-timer.low {
  background: var(--danger-50);
  color: var(--danger);
}

.score-big {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
}

/* emails & phone numbers: always read left-to-right, but align with the page */
.ltr-text {
  unicode-bidi: plaintext;
}

/* with plaintext, "start" follows the text itself, so pin it to the page's side */
[dir='rtl'] .ltr-text {
  text-align: right;
}

[dir='ltr'] .ltr-text {
  text-align: left;
}

/* ---------- pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.pager-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager-page {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
}

.pager-page:hover {
  background: var(--surface-2);
}

.pager-page.current {
  background: var(--primary-solid);
  color: #fff;
}

.pager-gap {
  color: var(--muted);
  padding: 0 2px;
}

.pager [aria-disabled='true'] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- start-up screen (index.html, taken down by app.js) ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  transition: opacity 0.4s ease, visibility 0.4s;
  /* never traps the page if the scripts fail to load */
  animation: splash-giveup 0.4s 10s forwards;
}

.splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-mark {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  box-shadow: 0 14px 34px rgba(3, 105, 161, 0.3);
  transition: transform 0.4s ease;
}

.splash.is-done .splash-mark {
  transform: scale(1.15);
}

.splash-name {
  font-family: 'Marhey', 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1.2;
}

.splash-name [lang='en'],
:root[lang='en'] .splash-name [lang='ar'] {
  display: none;
}

:root[lang='en'] .splash-name [lang='en'] {
  display: inline;
}

.splash-bar {
  width: 132px;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--primary-50);
  direction: ltr;
}

.splash-bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

@keyframes splash-giveup {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* ---------- motion ---------- */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
}

@keyframes splash-pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.06);
  }
}

@keyframes splash-dot {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes splash-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .splash-mark {
    animation: splash-pop 0.5s ease-out backwards;
  }

  .splash-mark circle {
    transform-box: fill-box;
    animation: splash-dot 0.9s ease-in-out 0.5s infinite;
  }

  .splash-name {
    animation: rise-in 0.45s ease-out 0.15s backwards;
  }

  .splash-bar {
    animation: fade-in 0.4s ease-out 0.3s backwards;
  }

  .splash-bar i {
    animation: splash-slide 1.1s ease-in-out infinite;
  }

  /* entrances wait behind the start-up screen and play once it lifts */
  .is-booting .navbar,
  .is-booting #app * {
    animation-play-state: paused !important;
  }

  .navbar {
    animation: fade-in 0.4s ease-out backwards;
  }

  /* every page slides up as it opens; the spinner only shows on slow loads */
  #app > :not(.loader) {
    animation: rise-in 0.35s ease-out backwards;
  }

  #app > .loader {
    animation: fade-in 0.3s ease-out 0.15s backwards;
  }

  /* cards come in one after the other */
  .grid > :is(.course-card, .tile, .stat),
  .nb-cards > .nb-card {
    animation: rise-in 0.45s ease-out backwards;
  }

  :is(.grid, .nb-cards) > :nth-child(2) {
    animation-delay: 0.06s;
  }
  :is(.grid, .nb-cards) > :nth-child(3) {
    animation-delay: 0.12s;
  }
  :is(.grid, .nb-cards) > :nth-child(4) {
    animation-delay: 0.18s;
  }
  :is(.grid, .nb-cards) > :nth-child(5) {
    animation-delay: 0.24s;
  }
  :is(.grid, .nb-cards) > :nth-child(n + 6) {
    animation-delay: 0.3s;
  }

  /* home hero: the text first, line by line, then the drawing */
  .zk-hero-body > * {
    animation: rise-in 0.5s ease-out backwards;
  }

  .zk-hero-body > :nth-child(1) {
    animation-delay: 0.1s;
  }
  .zk-hero-body > :nth-child(2) {
    animation-delay: 0.18s;
  }
  .zk-hero-body > :nth-child(3) {
    animation-delay: 0.26s;
  }
  .zk-hero-body > :nth-child(4) {
    animation-delay: 0.34s;
  }
  .zk-hero-body > :nth-child(5) {
    animation-delay: 0.42s;
  }

  .zk-hero-art {
    animation: pop-in 0.7s ease-out 0.25s backwards;
  }

  /* sections marked by reveal() in ui.js fade in when scrolled to */
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  }

  .reveal.in {
    opacity: 1;
    transform: none;
  }

  .modal-backdrop {
    animation: fade-in 0.2s ease-out;
  }

  .modal {
    animation: pop-in 0.25s ease-out;
  }
}

/* ---------- teacher reviews ---------- */
.stars {
  color: #f59e0b;
  letter-spacing: 1px;
  white-space: nowrap;
}

.stars-off {
  color: var(--border);
}

.rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rating-summary {
  margin: -6px 0 14px;
}

.review-form {
  margin-bottom: 18px;
}

/* inputs come 5…1 so `~` can light up a star and every one below it */
.stars-input {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 4px;
}

.stars-input input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.field .stars-input label {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--border);
  transition: color 0.15s, transform 0.15s;
}

.stars-input input:checked ~ label {
  color: #f59e0b;
}

/* while hovering, preview the hovered star instead of the chosen one */
.stars-input:hover input ~ label {
  color: var(--border);
}

.stars-input:hover label:hover,
.stars-input:hover label:hover ~ label {
  color: #f59e0b;
}

.stars-input label:hover {
  transform: scale(1.15);
}

.stars-input input:focus-visible + label {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.review-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.review-who {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.review-text {
  margin: 12px 0 0;
}

.rating-overview {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.rating-big {
  text-align: center;
}

.rating-big .value {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.rating-big .stars {
  font-size: 1.2rem;
}

.rating-bars {
  flex: 1;
  min-width: 220px;
  display: grid;
  gap: 6px;
}

.rating-bar {
  display: grid;
  grid-template-columns: 36px 1fr 28px;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

/* ---------- paid courses & access codes ---------- */
.course-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.course-price strong {
  font-size: 1.5rem;
  color: var(--accent);
}

.code-form {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 460px;
}

.code-form label {
  font-weight: 700;
}

.code-row {
  display: flex;
  gap: 8px;
}

.code-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.renew summary {
  cursor: pointer;
  margin-bottom: 10px;
}

.expiry {
  margin-top: 4px;
  color: var(--muted);
}

.expiry.expired {
  color: var(--danger);
  font-weight: 700;
}

.access-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* ---------- earnings ---------- */
.stat-warning .value {
  color: var(--warning);
}

/* ---------- purchases by transfer ---------- */
.pay-steps p {
  margin: 0 0 8px;
}

.pay-targets {
  list-style: none;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  gap: 6px;
}

.pay-number {
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.purchase {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

.purchase .receipt {
  flex: none;
  width: 130px;
  min-height: 170px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}

.purchase .receipt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* the student sent the request without a screenshot */
.purchase .receipt-none {
  align-content: center;
  gap: 6px;
  border-style: dashed;
  font-size: 1.8rem;
}

.purchase .receipt-none .small {
  font-size: 0.8rem;
}

.purchase-info {
  flex: 1;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 14px;
}

.purchase-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.purchase-head h3 {
  margin: 0 0 2px;
  font-size: 1.05rem;
}

.purchase-head .badge {
  flex: none;
}

.purchase-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.purchase-fact {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.purchase-note {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-50);
  color: var(--danger);
}

.pending-alert {
  display: block;
  margin-bottom: 18px;
  text-decoration: none;
}

@media (max-width: 640px) {
  .purchase {
    flex-direction: column;
  }

  .purchase .receipt {
    width: 100%;
    height: 200px;
  }
}
