@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&family=Tajawal:wght@300;400;500;700;800&display=swap');

@font-face {
  font-family: 'Uthman Hafs';
  src: url('/fonts/UthmanicHafs1-Ver09.woff2') format('woff2'),
       url('/fonts/UthmanicHafs1-Ver09.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary-color: #4361ee;
  --primary-light: #6b82f5;
  --primary-dark: #2e44b3;
  --secondary-color: #3f37c9;
  --accent-color: #f72585;
  --accent-light: #f85a9f;
  --bg-color: #f4f7f6;
  --text-color: #2b2d42;
  --text-muted: #6b7280;
  --card-bg: #ffffff;
  --surface-bg: #ffffff;
  --surface-muted: #f8fafc;
  --surface-elevated: #ffffff;
  --surface-border: #dbe3ee;
  --surface-hover: #eef4ff;
  --border-radius: 16px;
  --border-radius-lg: 24px;
  --shadow-sm: 0 4px 6px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 32px 64px rgba(0,0,0,0.14);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-slow: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: 'Cairo', 'Tajawal', sans-serif;
  --font-body: 'Tajawal', sans-serif;
}

html[data-theme="dark"] {
  --bg-color: #0f172a;
  --text-color: #f1f5f9;
  --text-muted: #94a3b8;
  --card-bg: #1e293b;
  --surface-bg: #111827;
  --surface-muted: #172033;
  --surface-elevated: #1e293b;
  --surface-border: #334155;
  --surface-hover: #24324a;
  --bs-body-bg: #0f172a;
  --bs-body-color: #f1f5f9;
  --bs-emphasis-color: #ffffff;
  --bs-secondary-color: #cbd5e1;
  --bs-secondary-bg: #1e293b;
  --bs-tertiary-bg: #172033;
  --bs-border-color: #334155;
  --bs-heading-color: #f8fafc;
  --bs-link-color: #93c5fd;
  --bs-link-hover-color: #bfdbfe;
  --shadow-sm: 0 4px 10px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 44px rgba(0,0,0,0.5);
  --shadow-xl: 0 32px 64px rgba(0,0,0,0.55);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
  overflow-x: auto;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: 'Tajawal', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  overflow-x: auto;
}

/* Validation summaries keep an empty hidden list before any validation errors exist. */
.validation-summary-valid {
  display: none;
}

.app-page-scroll {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
}

.app-page-scroll > header,
.app-page-scroll > .container,
.app-page-scroll > .container-fluid,
.app-page-scroll > footer {
  min-width: 0;
}

.app-page-scroll > .container,
.app-page-scroll > .container-fluid {
  flex: 1 0 auto;
  width: 100%;
}

body.page-with-bg {
    background:
        radial-gradient(circle at 20% 20%, rgba(67, 97, 238, 0.08), transparent 40%),
        radial-gradient(circle at 80% 15%, rgba(247, 37, 133, 0.05), transparent 35%),
        radial-gradient(circle at 50% 85%, rgba(59, 130, 246, 0.06), transparent 38%),
        linear-gradient(180deg, #f5f8ff 0%, #eef4ff 50%, #f0f5fa 100%);
    position: relative;
}

body.page-with-bg::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.14);
    z-index: 0;
    pointer-events: none;
}

body.page-with-bg::after {
    content: '';
    position: fixed;
    inset: -14%;
    background:
        radial-gradient(circle at 14% 18%, rgba(186, 230, 253, 0.84) 0%, rgba(186, 230, 253, 0.44) 18%, transparent 42%),
        radial-gradient(circle at 84% 16%, rgba(125, 211, 252, 0.72) 0%, rgba(125, 211, 252, 0.34) 16%, transparent 40%),
        radial-gradient(circle at 72% 80%, rgba(224, 242, 254, 0.88) 0%, rgba(191, 219, 254, 0.30) 22%, transparent 45%),
        radial-gradient(circle at 18% 78%, rgba(147, 197, 253, 0.52) 0%, rgba(147, 197, 253, 0.18) 16%, transparent 36%);
    transform: translate3d(0, 0, 0) scale(1.05);
    opacity: 0.9;
    z-index: 0;
    pointer-events: none;
    animation: maliSkyDrift 24s ease-in-out infinite alternate, maliSkyPulse 14s ease-in-out infinite;
}

body.page-with-bg .container {
    position: relative;
    z-index: 1;
}

html[data-theme="dark"] body.page-with-bg::before {
    background: rgba(7, 11, 24, 0.18);
}

html[data-theme="dark"] body.page-with-bg::after {
    background:
        radial-gradient(circle at 16% 20%, rgba(56, 189, 248, 0.18) 0%, rgba(56, 189, 248, 0.08) 18%, transparent 42%),
        radial-gradient(circle at 86% 18%, rgba(96, 165, 250, 0.16) 0%, rgba(96, 165, 250, 0.06) 18%, transparent 40%),
        radial-gradient(circle at 72% 80%, rgba(125, 211, 252, 0.14) 0%, rgba(125, 211, 252, 0.05) 22%, transparent 45%),
        radial-gradient(circle at 18% 78%, rgba(147, 197, 253, 0.12) 0%, rgba(147, 197, 253, 0.04) 16%, transparent 36%);
    opacity: 0.78;
}

html[data-theme="dark"] body.page-with-bg {
    background:
        radial-gradient(circle at 20% 18%, rgba(67, 97, 238, 0.15), transparent 38%),
        radial-gradient(circle at 82% 22%, rgba(56, 189, 248, 0.10), transparent 34%),
        radial-gradient(circle at 50% 85%, rgba(99, 102, 241, 0.08), transparent 40%),
        linear-gradient(180deg, #0b1225 0%, #0f172a 40%, #111827 100%);
}

.mali-hero {
    position: relative;
    overflow: hidden;
    margin: 2rem 0 3rem;
    padding: clamp(2rem, 5vw, 3.5rem);
    border-radius: var(--border-radius-lg);
    background: transparent;
    border: 1px solid rgba(186, 230, 253, 0.58);
    box-shadow: 0 24px 68px rgba(125, 211, 252, 0.22), inset 0 1px 1px rgba(255, 255, 255, 0.3);
    isolation: isolate;
}

.mali-hero::before,
.mali-hero::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.mali-hero::before {
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.56) 0%, rgba(240, 249, 255, 0.42) 28%, rgba(221, 244, 255, 0.48) 52%, rgba(255, 255, 255, 0.40) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
    z-index: 0;
}

.mali-hero::after {
    inset: -18%;
    border-radius: 42%;
    background:
        radial-gradient(circle at 24% 26%, rgba(186, 230, 253, 0.76) 0%, rgba(186, 230, 253, 0.26) 20%, transparent 44%),
        radial-gradient(circle at 76% 30%, rgba(125, 211, 252, 0.66) 0%, rgba(125, 211, 252, 0.20) 18%, transparent 40%),
        radial-gradient(circle at 64% 78%, rgba(224, 242, 254, 0.76) 0%, rgba(191, 219, 254, 0.18) 18%, transparent 38%);
    filter: blur(12px);
    opacity: 0.86;
    transform-origin: center;
    animation: maliHeroSkyFloat 19s ease-in-out infinite alternate;
    z-index: 0;
}

.mali-hero-backdrop {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(120deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.32) 48%, rgba(255,255,255,0.04) 100%);
    transform: translateX(-100%);
    animation: maliSweep 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

.landing-ui-controls {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    isolation: isolate;
}

html[dir="rtl"] .landing-ui-controls {
    right: auto;
    left: 1.25rem;
}

.landing-ui-btn {
    position: relative;
    z-index: 1201;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(67, 97, 238, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.6);
    transition: var(--transition);
}

.landing-ui-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
    box-shadow: 0 12px 28px rgba(67, 97, 238, 0.2);
}

html[data-theme="dark"] .landing-ui-btn {
    background: rgba(17, 24, 39, 0.72);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e5eefc;
}

html[data-theme="dark"] .landing-ui-btn:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(148, 163, 184, 0.5);
}

@media (max-width: 767.98px) {
    .landing-ui-controls {
        top: 0.9rem;
        right: 0.9rem;
    }

    html[dir="rtl"] .landing-ui-controls {
        left: 0.9rem;
    }
}

.mali-hero-inner {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3rem);
}

.mali-logo-stage {
    position: relative;
    min-height: 320px;
    display: grid;
    place-items: center;
}

.mali-canvas-wrap {
    width: 100%;
    height: 100%;
    min-height: 320px;
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.mali-brand-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.mali-orbit {
    position: absolute;
    inset: 50%;
    border-radius: 999px;
    border: 1px solid rgba(67, 97, 238, 0.14);
    transform: translate(-50%, -50%);
}

.mali-orbit-1 {
    width: 220px;
    height: 220px;
    animation: maliOrbitSpin 16s linear infinite;
}

.mali-orbit-2 {
    width: 310px;
    height: 310px;
    border-style: dashed;
    animation: maliOrbitSpinReverse 20s linear infinite;
}

.mali-letter {
    position: absolute;
    top: 50%;
    left: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(4.2rem, 8vw, 5.6rem);
    height: clamp(4.2rem, 8vw, 5.6rem);
    margin: calc(clamp(4.2rem, 8vw, 5.6rem) / -2);
    border-radius: 24px;
    background: linear-gradient(145deg, var(--secondary-color), #2647b8);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 18px 40px rgba(67, 97, 238, 0.2);
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #ffffff;
    animation: maliCycle 6.8s cubic-bezier(0.2, 0.9, 0.22, 1) infinite;
}

.mali-letter-m {
    --start-x: -320px;
    --start-y: 0px;
    --end-x: -144px;
    --end-y: 0px;
    animation-delay: 0.05s, 3.2s;
}

.mali-letter-a {
    --start-x: 0px;
    --start-y: -300px;
    --end-x: -48px;
    --end-y: 0px;
    animation-delay: 0.2s, 3.35s;
}

.mali-letter-l {
    --start-x: 0px;
    --start-y: 300px;
    --end-x: 48px;
    --end-y: 0px;
    animation-delay: 0.35s, 3.5s;
}

.mali-letter-i {
    --start-x: 320px;
    --start-y: 0px;
    --end-x: 144px;
    --end-y: 0px;
    animation-delay: 0.5s, 3.65s;
}

.mali-hero-eyebrow {
    margin-bottom: 0.7rem;
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-color);
    animation: maliFadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mali-hero-copy {
    max-width: 40rem;
}

.mali-hero:not(.teacher-home-hero) .mali-hero-copy {
    padding: 2rem 2.25rem;
    border-radius: var(--border-radius-lg);
    background: linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.25) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 18px 38px rgba(67, 97, 238, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.mali-hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.8rem;
    animation: maliFadeUp 0.8s 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mali-hero-actions .btn {
    border-radius: 999px;
    padding: 0.75rem 2rem;
    font-weight: 700;
    font-size: 1.05rem;
    transition: var(--transition);
    letter-spacing: 0.02em;
}

.mali-hero-actions .btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    box-shadow: 0 8px 24px rgba(67, 97, 238, 0.35);
}

.mali-hero-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(67, 97, 238, 0.45);
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.mali-hero-actions .btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.mali-hero-actions .btn-outline-primary:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(67, 97, 238, 0.25);
}

.mali-hero-tagline {
    margin-bottom: 0.75rem;
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 2.8vw, 1.85rem);
    font-weight: 800;
    color: #1d4ed8;
    text-shadow: 0 1px 0 rgba(255,255,255,0.9);
    line-height: 1.4;
    animation: maliFadeUp 0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mali-hero-subtitle {
    margin: 0 auto;
    max-width: 36rem;
    font-size: 1.1rem;
    color: #1e293b;
    text-shadow: 0 1px 0 rgba(255,255,255,0.72);
    line-height: 1.7;
    animation: maliFadeUp 0.8s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mali-tagline-brand {
    color: #d62828;
    font-weight: 800;
}

html[data-theme="dark"] .mali-hero {
    background: transparent;
    border-color: rgba(96, 165, 250, 0.16);
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .mali-hero::before {
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.72) 0%, rgba(14, 35, 58, 0.54) 30%, rgba(12, 33, 58, 0.48) 58%, rgba(15, 23, 42, 0.64) 100%);
    box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.08);
}

html[data-theme="dark"] .mali-hero::after {
    opacity: 0.34;
    filter: blur(18px);
}

html[data-theme="dark"] .mali-orbit {
    border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .mali-canvas-wrap {
    background: transparent;
    border: none;
    box-shadow: none;
}

html[data-theme="dark"] .mali-letter {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.96), rgba(37, 99, 235, 0.62));
    border-color: rgba(96, 165, 250, 0.32);
    color: #f8fbff;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .mali-hero-eyebrow {
    color: #93c5fd;
}

html[data-theme="dark"] .mali-hero-tagline {
    color: #e0f2fe;
    text-shadow: 0 0 24px rgba(59, 130, 246, 0.3);
    letter-spacing: 0.01em;
}

html[data-theme="dark"] .mali-hero-subtitle {
    color: #cbd5e1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .mali-hero-copy .mali-hero-tagline,
html[data-theme="dark"] .mali-hero-copy .mali-hero-subtitle {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] .mali-hero:not(.teacher-home-hero) .mali-hero-copy {
    background: linear-gradient(180deg, rgba(15,23,42,0.65) 0%, rgba(15,23,42,0.4) 100%);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

html[data-theme="dark"] .mali-hero-actions .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

html[data-theme="dark"] .mali-hero-actions .btn-primary:hover {
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.4);
}

html[data-theme="dark"] .mali-hero-actions .btn-outline-primary {
    border-color: #60a5fa;
    color: #93c5fd;
}

html[data-theme="dark"] .mali-hero-actions .btn-outline-primary:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

html[data-theme="dark"] .footer-signature-line {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(148, 163, 184, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .table,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .footer {
  color: var(--text-color);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .footer {
  background-color: var(--card-bg);
}

html[data-theme="dark"] .table thead th {
  background: linear-gradient(135deg, #1e3a5f, #1a2d4a);
  color: #e0f2fe;
  border-bottom: none;
}

html[data-theme="dark"] .table tbody td {
  color: #e2e8f0;
  border-bottom-color: #1e293b;
  background-color: #0f172a;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #131d31;
}

html[data-theme="dark"] .table-hover tbody tr:hover > * {
  background-color: #1a2744 !important;
}

html[data-theme="dark"] .table-responsive {
  border-color: #1e293b;
  background-color: #0f172a;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] pre {
  background-color: #111827;
  color: #f9fafb;
  border-color: #374151;
}

html[data-theme="dark"] .form-label {
  color: #e5e7eb;
}

html[data-theme="dark"] .prompt-preview-box {
  background-color: #111827;
  color: #f9fafb;
  border-color: #374151;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .small.text-muted {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary {
  color: #dbeafe;
}

.navbar-utility-cluster {
  position: relative;
  z-index: 1200;
  isolation: isolate;
  flex-wrap: nowrap;
}

.school-digital-clock {
  min-width: 106px;
  min-height: 42px;
  padding: 4px 11px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 12px;
  background: rgba(8, 24, 72, 0.22);
  color: #fff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.school-digital-clock-country {
  margin-bottom: 3px;
  font-size: 0.67rem;
  font-weight: 700;
  opacity: 0.86;
}

.school-digital-clock-time {
  font-family: "Cascadia Mono", "IBM Plex Mono", monospace;
  font-size: 0.96rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.navbar-icon-btn {
  position: relative;
  z-index: 1201;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

/* Header & Navbar */
.navbar {
  background: linear-gradient(135deg, #020617, #0b1120) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  padding: 1rem 0;
  border-bottom: none;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.navbar-brand-icon {
  width: 2.1rem;
  height: 2.1rem;
  object-fit: contain;
  border-radius: 0.7rem;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.student-tests-badge {
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.38rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.28);
}

html[data-theme="dark"] .navbar-brand-icon {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.4);
}

.nav-link {
  font-weight: 500;
  font-size: 1.05rem;
  transition: var(--transition);
  border-radius: 8px;
  padding: 0.6rem 1.2rem !important;
  margin: 0 0.3rem;
  color: rgba(255,255,255,0.85) !important;
}

.nav-link:hover, .nav-link.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff !important;
  transform: translateY(-2px);
}

/* Breadcrumb */
.breadcrumb {
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.breadcrumb-item a {
  color: var(--primary-color);
  text-decoration: none;
}
.breadcrumb-item a:hover {
  text-decoration: underline;
}
.breadcrumb-item.active {
  color: var(--text-muted);
}

/* Navbar dropdown */
.navbar .dropdown-menu {
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: 12px;
  margin-top: 0.5rem;
  min-width: 200px;
}
.navbar .dropdown-item {
  padding: 0.6rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition);
}
.navbar .dropdown-item i {
  margin-left: 0.5rem;
  width: 1.2rem;
  text-align: center;
}
html[data-theme="dark"] .navbar .dropdown-menu {
  background-color: var(--card-bg);
}
html[data-theme="dark"] .navbar .dropdown-item {
  color: var(--text-color);
}
html[data-theme="dark"] .navbar .dropdown-item:hover {
  background-color: rgba(255,255,255,0.08);
}

/* Tabs inside page content (not navbar) */
.nav-tabs .nav-link {
  color: #495057 !important;
  background-color: transparent;
  border-radius: 0;
  transform: none;
  margin: 0;
  padding: 0.6rem 1.2rem !important;
}

.nav-tabs .nav-link:hover {
  color: var(--primary-color) !important;
  background-color: transparent;
  transform: none;
}

.nav-tabs .nav-link.active {
  color: var(--primary-color) !important;
  background-color: var(--card-bg);
  border-color: #dee2e6 #dee2e6 var(--card-bg);
  transform: none;
}

html[data-theme="dark"] .nav-tabs .nav-link {
  color: #9ca3af !important;
}

html[data-theme="dark"] .nav-tabs .nav-link:hover {
  color: #60a5fa !important;
}

html[data-theme="dark"] .nav-tabs .nav-link.active {
  color: #60a5fa !important;
  background-color: var(--card-bg);
  border-color: #374151 #374151 var(--card-bg);
}

/* Main Container & Cards */
.container {
  max-width: 1200px;
}

.card {
  border: none;
  border-radius: var(--border-radius);
  background-color: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  margin-bottom: 2rem;
  overflow: hidden;
}

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

.card-header {
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), rgba(63, 55, 201, 0.03));
  border-bottom: 1px solid rgba(67, 97, 238, 0.08);
  font-weight: 700;
  padding: 1.25rem 1.5rem;
  font-size: 1.15rem;
  color: var(--secondary-color);
}

.card-body {
  padding: 1.5rem;
}

html[data-theme="dark"] .card-header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(37, 99, 235, 0.05));
  border-bottom-color: rgba(148, 163, 184, 0.1);
}

/* Buttons - Unified Theme */
.btn {
  border-radius: 10px;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.96) !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(67, 97, 238, 0.4);
  background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
  color: white;
}

.btn-outline-primary {
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(67, 97, 238, 0.25);
}

.btn-outline-secondary {
  color: #475569;
  border: 2px solid #cbd5e1;
  background: transparent;
}

.btn-outline-secondary:hover {
  background: #475569;
  border-color: #475569;
  color: #fff;
  transform: translateY(-2px);
}

.btn-outline-dark {
  color: #1e293b;
  border: 2px solid #1e293b;
  background: transparent;
}

.btn-outline-dark:hover {
  background: #1e293b;
  color: #fff;
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.4);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
  color: white;
}

.btn-info {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: white;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.3);
}

.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.4);
  color: white;
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
  color: white;
}

.btn-secondary {
  background: linear-gradient(135deg, #64748b, #475569);
  color: white;
  box-shadow: 0 4px 14px rgba(100, 116, 139, 0.3);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(100, 116, 139, 0.4);
  color: white;
}

.btn-lg {
  padding: 0.8rem 2rem;
  font-size: 1.1rem;
  border-radius: 999px;
}

.btn-sm {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* Dark theme unified buttons — swap to outline style */
html[data-theme="dark"] .btn-primary {
  background: transparent;
  border-color: #60a5fa;
  color: #93c5fd;
  box-shadow: none;
}

html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn-primary:focus {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

html[data-theme="dark"] .btn-outline-primary {
  border-color: #60a5fa;
  color: #93c5fd;
}

html[data-theme="dark"] .btn-outline-primary:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

html[data-theme="dark"] .btn-outline-secondary {
  border-color: #64748b;
  color: #94a3b8;
}

html[data-theme="dark"] .btn-outline-secondary:hover {
  background: #475569;
  border-color: #475569;
  color: #fff;
}

html[data-theme="dark"] .btn-outline-dark {
  border-color: #94a3b8;
  color: #cbd5e1;
}

html[data-theme="dark"] .btn-outline-dark:hover {
  background: #64748b;
  border-color: #64748b;
  color: #fff;
}

html[data-theme="dark"] .btn-success {
  background: transparent;
  border-color: #4ade80;
  color: #86efac;
  box-shadow: none;
}

html[data-theme="dark"] .btn-success:hover {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.2);
}

html[data-theme="dark"] .btn-danger {
  background: transparent;
  border-color: #ef4444;
  color: #f87171;
  box-shadow: none;
}

html[data-theme="dark"] .btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

html[data-theme="dark"] .btn-info {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

html[data-theme="dark"] .btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

html[data-theme="dark"] .btn-secondary {
  background: linear-gradient(135deg, #64748b, #475569);
}

/* Login page button overrides */
.login-brand-layout .btn-primary {
    border-radius: 999px;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.login-brand-layout .btn-outline-primary {
    border-radius: 999px;
    padding: 0.7rem 1.5rem;
    font-weight: 700;
}

.teacher-register-btn:hover,
.teacher-register-btn:focus {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus {
  outline: none;
  box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.3);
}

/* Forms & Inputs */
.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  padding: 0.75rem 1.1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  background-color: #f8fafc;
  color: #1e293b;
  font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-label {
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.45rem;
  font-size: 0.95rem;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
  border-color: #3b82f6;
  background-color: #1e293b;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

html[data-theme="dark"] .form-label {
  color: #cbd5e1;
}

.form-check-input {
    border-radius: 4px;
    border: 2px solid #cbd5e1;
    transition: var(--transition);
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

html[data-theme="dark"] .form-check-input {
    border-color: #475569;
    background-color: transparent;
}

html[data-theme="dark"] .form-check-input:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Tables */
.table-responsive {
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  background-color: white;
  margin-bottom: 2rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.table thead th {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-bottom: none;
  color: #ffffff;
  font-weight: 700;
  padding: 1rem 1rem;
  white-space: nowrap;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.table thead th:first-child {
  border-radius: 12px 0 0 0;
}

.table thead th:last-child {
  border-radius: 0 12px 0 0;
}

.table tbody td {
  padding: 1rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
  background-color: #ffffff;
  transition: background-color 0.2s ease;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #f8fafc;
}

.table-hover tbody tr {
  transition: all 0.2s ease;
}

.table-hover tbody tr:hover > * {
  background-color: #eef2ff !important;
}

.table-hover tbody tr:hover {
  transform: scale(1.005);
}

.table-responsive {
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  background-color: white;
  margin-bottom: 2rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e2e8f0;
}

/* Footer */
.footer {
  background-color: transparent;
  box-shadow: none;
  font-weight: 500;
  padding: 1.5rem 0;
  position: static !important;
  margin-top: auto;
  flex-shrink: 0;
  width: 100%;
  border-top: none !important;
  z-index: 0;
  clear: both;
}

.app-main-content {
  padding-bottom: 1rem !important;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-weight: 800;
  color: var(--secondary-color);
  margin-bottom: 1.5rem;
}

/* Alert */
.alert {
  border-radius: 12px;
  border: none;
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}

.alert-success {
  background-color: #d1e7dd;
  color: #0f5132;
}

/* Badges */
.badge {
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1; 
}
::-webkit-scrollbar-thumb {
  background: #c1c1c1; 
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color); 
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes maliCycle {
    0% {
        opacity: 0;
        transform: translate(var(--start-x), var(--start-y)) scale(0.35) rotate(-18deg);
        box-shadow: 0 10px 24px rgba(67, 97, 238, 0.12);
        filter: blur(10px);
    }
    14% {
        opacity: 1;
        transform: translate(calc(var(--start-x) * 0.55), calc(var(--start-y) * 0.55)) scale(0.72) rotate(-10deg);
        filter: blur(4px);
    }
    34% {
        opacity: 1;
        transform: translate(calc(var(--end-x) * 1.12), calc(var(--end-y) - 8px)) scale(1.08) rotate(4deg);
        box-shadow: 0 24px 54px rgba(67, 97, 238, 0.28);
        filter: blur(0);
    }
    44%,
    58% {
        opacity: 1;
        transform: translate(var(--end-x), var(--end-y)) scale(1) rotate(0deg);
        box-shadow: 0 24px 54px rgba(67, 97, 238, 0.28);
        filter: drop-shadow(0 0 18px rgba(67, 97, 238, 0.28));
    }
    72% {
        opacity: 1;
        transform: translate(calc(var(--end-x) * 1.06), calc(var(--start-y) * 0.18)) scale(0.82) rotate(-6deg);
        box-shadow: 0 14px 28px rgba(67, 97, 238, 0.16);
        filter: blur(3px);
    }
    100% {
        opacity: 0;
        transform: translate(var(--start-x), var(--start-y)) scale(0.35) rotate(-18deg);
        box-shadow: 0 10px 24px rgba(67, 97, 238, 0.12);
        filter: blur(10px);
    }
}

@keyframes maliOrbitSpin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes maliOrbitSpinReverse {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes maliSkyDrift {
    0% {
        transform: translate3d(-3%, -2%, 0) scale(1.04) rotate(0deg);
    }
    50% {
        transform: translate3d(3%, 2%, 0) scale(1.12) rotate(4deg);
    }
    100% {
        transform: translate3d(-2%, 4%, 0) scale(1.08) rotate(-3deg);
    }
}

@keyframes maliSkyPulse {
    0%, 100% {
        opacity: 0.82;
    }
    50% {
        opacity: 1;
    }
}

@keyframes maliHeroSkyFloat {
    0% {
        transform: translate3d(-4%, -3%, 0) scale(1.02) rotate(0deg);
    }
    50% {
        transform: translate3d(3%, 2%, 0) scale(1.08) rotate(3deg);
    }
    100% {
        transform: translate3d(-1%, 5%, 0) scale(1.05) rotate(-2deg);
    }
}

@keyframes maliSweep {
    0%, 100% {
        transform: translateX(-100%);
        opacity: 0;
    }
    18%, 62% {
        opacity: 1;
    }
    50% {
        transform: translateX(100%);
        opacity: 0.75;
    }
}

@keyframes maliFadeUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

main {
  animation: fadeInUp 0.7s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (prefers-reduced-motion: reduce) {
    body.page-with-bg::after,
    .mali-hero::after,
    .mali-hero-backdrop,
    .mali-hero-eyebrow,
    .mali-hero-tagline,
    .mali-hero-subtitle,
    .mali-hero-actions,
    main {
        animation: none !important;
    }
}

.font-monospace {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.prompt-preview-box {
    min-height: 7rem;
    white-space: pre-wrap;
    resize: vertical;
    background: #f8fafc;
    color: #111827;
}

.import-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.section-toggle-chevron {
    font-size: 1rem;
    opacity: 0.85;
}

.ai-sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.ai-site-tile {
    position: relative;
    border: 1px solid rgba(67, 97, 238, 0.18);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    min-height: 132px;
    transition: var(--transition);
    color: #111827;
    text-decoration: none;
}

.ai-site-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(67, 97, 238, 0.34);
}

.ai-site-icon {
    width: 3.3rem;
    height: 3.3rem;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.45rem;
    box-shadow: 0 10px 18px rgba(0,0,0,0.12);
}

.ai-site-icon-image-frame {
    background: #ffffff;
    padding: 0.35rem;
}

.ai-site-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 0.75rem;
}

.ai-site-icon-claude {
    background: linear-gradient(135deg, #d97706, #f97316);
}

.ai-site-icon-gemini {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.ai-site-icon-deepseek {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.ai-site-icon-google {
    background: linear-gradient(135deg, #ea4335, #4285f4);
}

.ai-site-icon-chatgpt {
    background: linear-gradient(135deg, #059669, #10b981);
}

.ai-site-icon-qwen {
    background: linear-gradient(135deg, #7c3aed, #ec4899);
}

.ai-site-name {
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
}

.ai-site-badge {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.3);
}

.ai-site-tile-recommended {
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 16px 28px rgba(34, 197, 94, 0.12);
}

.ai-site-icon-fallback {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.ai-sites-admin-list {
    display: grid;
    gap: 1rem;
}

.ai-site-admin-item {
    padding: 1rem;
    border: 1px solid rgba(67, 97, 238, 0.12);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(247,250,255,0.96) 100%);
}

.subject-prompt-panel {
    margin: 0;
    padding: 1.15rem 1.15rem 1.25rem;
    border: 3px solid rgba(67, 97, 238, 0.42);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.99) 0%, rgba(247,250,255,0.97) 100%);
    box-shadow: 0 12px 28px rgba(67, 97, 238, 0.10);
}

.subject-prompt-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.subject-prompt-panel-title-wrap {
    min-width: min(100%, 22rem);
    flex: 1 1 22rem;
}

.subject-prompt-panel-title-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}

.subject-prompt-save-btn {
    min-width: 8.5rem;
}

.ai-site-admin-badge {
    align-self: center;
}

html[data-theme="dark"] .ai-site-tile {
    background: linear-gradient(180deg, #111827 0%, #182234 100%);
    color: #f9fafb;
    border-color: #334155;
}

html[data-theme="dark"] .ai-site-icon-image-frame {
    background: #f8fafc;
}

html[data-theme="dark"] .ai-site-admin-item {
    background: linear-gradient(180deg, #111827 0%, #182234 100%);
    border-color: #334155;
}

html[data-theme="dark"] .subject-prompt-panel {
    background: linear-gradient(180deg, #111827 0%, #182234 100%);
    border-color: rgba(96, 165, 250, 0.72);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .question-diagram-box,
html[data-theme="dark"] .jsxgraph-diagram,
html[data-theme="dark"] .question-diagram-svg,
html[data-theme="dark"] .question-stem-surface,
html[data-theme="dark"] .school-admin-card,
html[data-theme="dark"] .student-card-print,
html[data-theme="dark"] .edit-diagram-grid-scale,
html[data-theme="dark"] .diagram-error,
html[data-theme="dark"] .exam-calc-panel {
    color: #e5e7eb;
}

html[data-theme="dark"] .question-diagram-box,
html[data-theme="dark"] .jsxgraph-diagram,
html[data-theme="dark"] .question-diagram-svg,
html[data-theme="dark"] .question-stem-surface,
html[data-theme="dark"] .school-admin-card {
    background: linear-gradient(180deg, #111827 0%, #182234 100%);
    border-color: #334155;
}

html[data-theme="dark"] .edit-diagram-grid-scale {
    background: rgba(15, 23, 42, 0.86);
    color: rgba(191, 219, 254, 0.92);
}

html[data-theme="dark"] .question-stem-surface,
html[data-theme="dark"] .school-admin-card,
html[data-theme="dark"] .student-card-print {
    border-color: rgba(96, 165, 250, 0.16);
}

html[data-theme="dark"] .diagram-error {
    background: linear-gradient(180deg, #2a1320 0%, #1f172a 100%);
    color: #fecdd3;
}

html[data-theme="dark"] .student-card-print {
    background: #182234;
}

html[data-theme="dark"] .student-card-print .student-card-body,
html[data-theme="dark"] .student-card-print h4,
html[data-theme="dark"] .student-card-print .student-card-line {
    color: #f3f4f6;
}

html[data-theme="dark"] .student-card-english {
    color: #cbd5e1;
}

html[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-table-striped-bg: #131d31;
    --bs-table-striped-color: #e2e8f0;
    --bs-table-hover-bg: #1a2744;
    --bs-table-hover-color: #f1f5f9;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #131d31;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: #0f172a;
}

html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .table-responsive .table,
html[data-theme="dark"] .table-responsive .table tbody {
    background-color: #0f172a;
}

html[data-theme="dark"] .table-responsive .table thead th {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a);
}

html[data-theme="dark"] .table-responsive .table tbody td {
    border-bottom-color: #1e293b;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-responsive {
    border-color: #1e293b;
    background-color: #0f172a;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-responsive .table thead th {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a);
    border-bottom-color: #2a3a55;
    color: #e0f2fe;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-responsive .table tbody td {
    background-color: #111827;
    color: #f8fafc;
    border-bottom-color: #334155;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #172033;
    color: #f8fafc;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: #111827;
    color: #f8fafc;
}

html[data-theme="dark"] body:not(.page-with-bg) .table-hover tbody tr:hover > * {
    background-color: #1e293b;
    color: #ffffff;
}

html[data-theme="dark"] .card .table,
html[data-theme="dark"] .card .table tbody,
html[data-theme="dark"] .card .table-striped > tbody > tr > *,
html[data-theme="dark"] .card .table > :not(caption) > * > * {
    color: #f3f4f6 !important;
}

html[data-theme="dark"] .card .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #182234 !important;
}

html[data-theme="dark"] .card .table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: #1f2937 !important;
}

html[data-theme="dark"] .card .table thead th {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a) !important;
    color: #e0f2fe !important;
}

html[data-theme="dark"] .student-cards-grid,
html[data-theme="dark"] .student-card-print,
html[data-theme="dark"] .student-card-body {
    background-color: #182234 !important;
}

html[data-theme="dark"] .prompt-preview-box {
    background: #111827;
}

html[data-theme="dark"] .table-hover tbody tr:hover > * {
    background-color: #1a2744 !important;
}

html[data-theme="dark"] .alert-success {
    background-color: #0f2f24;
    color: #d1fae5;
}

pre {
    direction: ltr;
    text-align: left;
    background-color: #2b2d42;
    color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.question-diagram-box,
.jsxgraph-diagram {
    width: 100%;
    min-height: 320px;
    height: 320px;
    border: 1px solid rgba(67, 97, 238, 0.18);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    overflow: hidden;
}

.question-diagram-svg {
    padding: 0.75rem;
    border: 1px solid rgba(67, 97, 238, 0.18);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.question-diagram-svg svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    font-family: "Times New Roman", Times, serif;
    text-rendering: geometricPrecision;
    font-kerning: none;
    direction: ltr;
    unicode-bidi: isolate;
}

.question-diagram-svg svg text,
.question-diagram-svg svg tspan {
    direction: ltr;
    unicode-bidi: bidi-override;
}

.question-diagram-svg svg .svg-draggable-node,
.exam-diagram-content svg .svg-draggable-node {
    cursor: move;
    user-select: none;
    touch-action: none;
    pointer-events: all;
}

.question-diagram-svg svg .svg-draggable-node.is-dragging,
.exam-diagram-content svg .svg-draggable-node.is-dragging,
.question-diagram-svg svg.is-dragging-shape .svg-draggable-node,
.exam-diagram-content svg.is-dragging-shape .svg-draggable-node {
    cursor: grabbing;
}

.edit-diagram-preview-frame svg .svg-draggable-label {
    cursor: move;
    user-select: none;
    touch-action: none;
    pointer-events: all;
}

.edit-diagram-preview-frame svg .svg-draggable-label.is-dragging,
.edit-diagram-preview-frame svg.is-dragging-label .svg-draggable-label {
    cursor: grabbing;
}

.question-diagram-image {
    display: block;
    max-width: 100%;
    max-height: 420px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}

.edit-diagram-preview-card .card-header {
    padding-bottom: 1rem;
}

.edit-diagram-preview-surface {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-diagram-preview-frame {
    width: 100%;
}

.edit-diagram-preview-grid {
    background-color: #ffffff;
    position: relative;
    overflow: hidden;
}

.edit-diagram-preview-grid::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(to right, rgba(67, 97, 238, 0.18) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(67, 97, 238, 0.18) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
    pointer-events: none;
    z-index: 2;
    border-radius: inherit;
}

.edit-diagram-grid-scale {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 3;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(67, 97, 238, 0.7);
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 6px;
    border-radius: 4px;
    pointer-events: none;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    direction: ltr;
    line-height: 1.4;
}

.edit-diagram-preview-empty {
    width: 100%;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border: 1px dashed rgba(67, 97, 238, 0.22);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #5c677d;
    text-align: center;
    font-weight: 600;
}

html[data-theme="dark"] .edit-diagram-preview-empty {
    background: linear-gradient(180deg, #111827 0%, #182234 100%);
    color: #cbd5e1;
    border-color: #334155;
}

html[data-theme="dark"] .edit-diagram-preview-grid {
    background-color: #0f172a;
    background-image:
        linear-gradient(to right, rgba(148, 163, 184, 0.18) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(148, 163, 184, 0.18) 1px, transparent 1px);
}

.edit-diagram-ruler-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    direction: ltr;
    z-index: 3;
}

.edit-diagram-ruler-mark {
    position: absolute;
    font-size: 9px;
    font-weight: 700;
    color: rgba(67, 97, 238, 0.5);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    line-height: 1;
    white-space: nowrap;
}

html[data-theme="dark"] .edit-diagram-ruler-mark {
    color: rgba(148, 163, 184, 0.5);
}

.question-body-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.question-body-layout.has-diagram {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.question-text-panel,
.question-visual-panel {
    min-width: 0;
}

.question-stem-surface {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    height: 100%;
    padding: 1rem 1.15rem;
    border: 1px dashed rgba(67, 97, 238, 0.22);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.question-body-layout .question-text {
    margin-bottom: 0;
}

.question-stem-copy {
    line-height: 1.9;
}

.formatted-rich-text-paragraph {
    margin: 0;
    line-height: 1.95;
}

.formatted-rich-text-paragraph + .formatted-rich-text-paragraph {
    margin-top: 0.65rem;
}

.quran-verse-block {
    margin: 0.45rem 0;
    padding: 0.9rem 1rem;
    border: 1px solid #d8bf7a;
    border-radius: 14px;
    background: linear-gradient(180deg, #fcf7e7 0%, #f7efd7 100%);
    color: #1f2937 !important;
    font-family: 'Uthman Hafs', 'Amiri', 'Traditional Arabic', serif !important;
    font-size: 1.65rem;
    line-height: 2.2;
    text-align: center;
    letter-spacing: 0;
    box-shadow: 0 10px 24px rgba(148, 117, 36, 0.10);
}

.rich-option-text {
    flex: 1 1 auto;
    min-width: 0;
}

.rich-option-text .formatted-rich-text-paragraph {
    font-size: inherit;
}

.rich-option-text .quran-verse-block {
    font-size: 1.45rem;
}

.question-diagram-svg text,
.question-diagram-box svg text,
.edit-diagram-preview-frame text {
    direction: ltr;
    unicode-bidi: embed;
}

html[data-theme="dark"] .quran-verse-block,
html[data-theme="dark"] .question-stem-copy .quran-verse-block,
html[data-theme="dark"] .rich-option-text .quran-verse-block {
    background: linear-gradient(180deg, #fcf7e7 0%, #f7efd7 100%) !important;
    color: #1f2937 !important;
    border-color: #d8bf7a !important;
}

.exam-review-font,
.exam-review-font .card,
.exam-review-font .card-body,
.exam-review-font .question-stem-surface,
.exam-review-font .question-stem-copy,
.exam-review-font .question-stem-meta,
.exam-review-font ul,
.exam-review-font li,
.exam-review-font p,
.exam-review-font .badge,
.exam-review-font .MathJax,
.exam-review-font mjx-container {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif !important;
}

.exam-review-font .question-stem-copy,
.exam-review-font li,
.exam-review-font p {
    font-size: 1.08rem;
    font-weight: 600;
}

.question-stem-surface .question-meta,
.question-stem-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    letter-spacing: normal;
}

.question-visual-panel {
    display: flex;
    align-items: stretch;
}

.question-visual-panel .question-diagram-box,
.question-visual-panel .question-diagram-svg {
    width: 100%;
    margin-bottom: 0 !important;
}

.question-visual-panel .question-diagram-svg {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .question-body-layout.has-diagram {
        grid-template-columns: 1fr;
    }
}

.diagram-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 1rem;
    color: #8b1e3f;
    background: #fff7fa;
    text-align: center;
    font-weight: 600;
}

.page-toolbar,
.action-cluster,
.table-actions,
.entity-meta,
.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-toolbar {
    align-items: flex-start;
    justify-content: space-between;
}

.action-cluster {
    align-items: center;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.compact-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.admin-stat-card {
    margin-bottom: 0;
}

.admin-stat-card .card-body {
    padding: 0.9rem 1rem;
}

.admin-stat-label {
    color: #5c677d;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.admin-stat-value {
    font-size: 1.55rem;
    line-height: 1.1;
    font-weight: 800;
    color: var(--secondary-color);
}

.school-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.school-class-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.school-admin-card {
    border: 1px solid rgba(67, 97, 238, 0.12);
    border-radius: 16px;
    padding: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: var(--shadow-sm);
}

.school-join-code {
    font-size: 0.95rem;
    color: var(--secondary-color);
    font-weight: 600;
}

.entity-meta {
    gap: 0.5rem 1rem;
    color: #5c677d;
    font-size: 0.95rem;
}

.entity-meta.vertical {
    flex-direction: column;
    align-items: flex-start;
}

.badge-list {
    gap: 0.5rem;
}

.inline-action-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.admin-teachers-table {
    min-width: 1120px;
}

.admin-teachers-table-wrap {
    width: 100%;
}

.admin-form-card {
    border: 1px solid rgba(67, 97, 238, 0.12);
}

.student-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.student-card-print {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(67, 97, 238, 0.14);
    box-shadow: var(--shadow-sm);
    break-inside: avoid;
    page-break-inside: avoid;
}

.student-card-header {
    padding: 1rem 1.2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.student-card-school {
    font-weight: 800;
    font-size: 1rem;
}

.student-card-meta {
    font-size: 0.92rem;
    opacity: 0.92;
}

.student-card-body {
    padding: 1rem 1.2rem 1.2rem;
}

.student-card-body h4 {
    margin-bottom: 0.35rem;
    font-size: 1.25rem;
}

.student-card-english {
    color: #5c677d;
    margin-bottom: 0.9rem;
}

.student-card-line {
    margin-bottom: 0.45rem;
    font-size: 0.98rem;
}

.student-exam-shell {
    position: relative;
    min-height: 100vh;
    padding: 1rem 0 2rem;
    isolation: isolate;
}

.student-exam-watermark {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    z-index: 1;
    opacity: 0.06;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    transform: rotate(-24deg);
    user-select: none;
}

.student-exam-watermark span {
    display: block;
}

.student-exam-shell .card {
    position: relative;
    z-index: 2;
}

.student-exam-blackout {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #000;
    color: #fff;
    z-index: 2147483000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    text-align: center;
    cursor: pointer;
}

.student-exam-blackout.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.student-exam-blackout-card {
    width: min(34rem, 100%);
}

.student-exam-blackout-title {
    margin-bottom: 0.85rem;
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 800;
}

.student-exam-blackout-text {
    font-size: 1rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.82);
}

.student-exam-launch-btn {
    margin-top: 1.25rem;
    min-width: min(20rem, 100%);
    font-weight: 800;
    border-radius: 999px;
    padding: 0.9rem 1.6rem;
    border: 1px solid rgba(147, 197, 253, 0.45) !important;
    background: linear-gradient(135deg, #4361ee 0%, #1d4ed8 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 16px 40px rgba(255, 255, 255, 0.08);
}

.student-exam-launch-btn:hover,
.student-exam-launch-btn:focus {
    background: linear-gradient(135deg, #3651d4 0%, #1e40af 100%) !important;
    color: #ffffff !important;
    border-color: rgba(191, 219, 254, 0.7) !important;
}

.exam-option {
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(67, 97, 238, 0.14);
    border-radius: 12px;
    margin-bottom: 0.6rem;
    background: rgba(255, 255, 255, 0.78);
}

html[data-theme="dark"] .exam-option {
    background: rgba(31, 41, 55, 0.92);
}

html[data-theme="dark"] .admin-stat-label,
html[data-theme="dark"] .entity-meta {
    color: #cbd5e1;
}

body.student-exam-mode {
    margin-bottom: 0;
    background: #000;
    overflow: hidden;
}

body.student-exam-mode .navbar,
body.student-exam-mode .footer {
    display: none !important;
}

body.student-exam-mode .container {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    padding-left: 0;
    padding-right: 0;
}

body.student-exam-mode main {
    height: 100vh;
    padding-bottom: 0 !important;
    overflow: hidden;
}

body.student-exam-mode .student-exam-shell {
    height: 100vh;
    overflow-y: auto;
    padding: 0;
}

body.student-exam-mode.exam-fullscreen-active .student-exam-shell {
    padding: 0;
}

body.student-exam-mode:not(.exam-fullscreen-active) .student-exam-shell {
    user-select: none;
}

body.student-exam-mode:not(.exam-fullscreen-active) .student-exam-shell > :not(.student-exam-blackout) {
    visibility: hidden;
}

.footer-signature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.footer-signature-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    white-space: nowrap;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.footer-platform {
    text-align: right;
    font-weight: 500;
    opacity: 0.85;
}

.footer-owner-line {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

.footer-owner {
    font-weight: 700;
    color: var(--text-color);
}

.login-brand-layout {
    margin-top: 1.5rem;
    min-height: calc(100vh - 220px);
    align-content: center;
}

.mali-login-hero {
    height: 100%;
    margin-bottom: 0;
}

.mali-login-hero-inner {
    grid-template-columns: 1fr;
    min-height: 100%;
    gap: 1.25rem;
}

.mali-login-hero .mali-hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mali-login-logo-stage {
    min-height: 260px;
}

.login-brand-layout .card {
    border-radius: var(--border-radius-lg);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 20px 48px rgba(67, 97, 238, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.login-brand-layout .card:hover {
    box-shadow: 0 24px 56px rgba(67, 97, 238, 0.16);
    transform: translateY(-2px);
}

.login-brand-layout .card-header {
    text-align: center;
    border-bottom: 1px solid rgba(67, 97, 238, 0.1);
    padding: 1.75rem 1.75rem 1rem;
    font-size: 1.5rem;
}

.login-brand-layout .card-body {
    padding: 1.75rem;
}

.login-brand-layout .card-footer {
    padding: 1rem 1.75rem 1.75rem;
    border-top: none;
    background: transparent;
}

html[data-theme="dark"] .login-brand-layout .card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: rgba(148, 163, 184, 0.15);
}

html[data-theme="dark"] .login-brand-layout .card-header {
    border-bottom-color: rgba(148, 163, 184, 0.1);
}

html[data-theme="dark"] .login-brand-layout .card-body .text-muted {
    color: #94a3b8 !important;
}

.dashboard-panel-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.dashboard-panel-link:hover,
.dashboard-panel-link:focus {
    color: inherit;
    text-decoration: none;
}

.teacher-home-hero {
    margin-bottom: 1.4rem;
}

.teacher-home-hero-inner {
    grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
    align-items: stretch;
    direction: ltr;
}

.teacher-home-panel-stack {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 1.15rem;
    align-self: stretch;
}

.teacher-home-card {
    margin-bottom: 0;
    min-height: 11.7rem;
    border: 1px solid rgba(67, 97, 238, 0.14);
    background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(243,247,255,0.94) 100%);
    box-shadow: 0 14px 28px rgba(67, 97, 238, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.teacher-home-card:hover,
.teacher-home-card:focus {
    transform: translateY(-6px) scale(1.035);
    border-color: rgba(67, 97, 238, 0.3);
    background: linear-gradient(180deg, rgba(236,242,255,0.98) 0%, rgba(224,234,255,0.96) 100%);
    box-shadow: 0 22px 42px rgba(67, 97, 238, 0.18);
}

.teacher-home-card .card-body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.8rem 1.4rem;
}

.teacher-home-card .card-title {
    margin-bottom: 0.9rem;
}

.teacher-home-card .card-text {
    margin-bottom: 0;
}

.teacher-home-logo-stage {
    min-height: 100%;
    padding-inline-start: 0.5rem;
}

html[data-theme="dark"] .teacher-home-card {
    background: linear-gradient(180deg, rgba(23, 34, 55, 0.96) 0%, rgba(21, 29, 48, 0.96) 100%);
    border-color: rgba(96, 165, 250, 0.16);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] .teacher-home-card:hover,
html[data-theme="dark"] .teacher-home-card:focus {
    background: linear-gradient(180deg, rgba(28, 44, 75, 0.98) 0%, rgba(25, 38, 64, 0.98) 100%);
    border-color: rgba(147, 197, 253, 0.34);
    box-shadow: 0 24px 46px rgba(0, 0, 0, 0.34);
}

.footer-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #25d366;
    text-decoration: none;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(37, 211, 102, 0.1);
    transition: var(--transition);
}

.footer-whatsapp:hover {
    color: #25d366;
    background: rgba(37, 211, 102, 0.2);
    text-decoration: none;
}

@media (max-width: 991.98px) {
    .mali-hero {
        padding: 1.4rem 1rem 1.7rem;
        border-radius: 24px;
    }

    .mali-hero-inner {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .teacher-home-hero-inner {
        grid-template-columns: 1fr;
    }

    .teacher-home-panel-stack {
        order: 2;
    }

    .teacher-home-logo-stage {
        order: 1;
        padding-inline-start: 0;
    }

    .mali-logo-stage {
        min-height: 260px;
    }

    .mali-canvas-wrap {
        min-height: 260px;
        border-radius: 20px;
    }

    .mali-orbit-1 {
        width: 180px;
        height: 180px;
    }

    .mali-orbit-2 {
        width: 240px;
        height: 240px;
    }

    .mali-letter-m {
        --start-x: -220px;
        --start-y: 0px;
        --end-x: -100px;
    }

    .mali-letter-a {
        --start-x: 0px;
        --start-y: -210px;
        --end-x: -34px;
    }

    .mali-letter-l {
        --start-x: 0px;
        --start-y: 210px;
        --end-x: 34px;
    }

    .mali-letter-i {
        --start-x: 220px;
        --start-y: 0px;
        --end-x: 100px;
    }

    .navbar {
        padding: 0.75rem 0;
    }

    .navbar-utility-cluster {
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-top: 0.65rem;
    }

    .school-digital-clock {
        min-width: 118px;
    }

    .navbar-brand {
        font-size: 1.3rem;
    }

    .navbar-brand-icon {
        width: 1.9rem;
        height: 1.9rem;
    }

    .nav-link {
        margin: 0;
        padding: 0.65rem 0.9rem !important;
    }

    .card:hover {
        transform: none;
    }

    .card-header,
    .card-body {
        padding: 1rem;
    }

    .container {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-cluster,
    .table-actions,
    .inline-action-form {
        flex-direction: column;
        align-items: stretch;
    }

    .action-cluster > .btn,
    .action-cluster > a,
    .table-actions > .btn,
    .table-actions > a,
    .table-actions > form,
    .inline-action-form > .btn,
    .inline-action-form > .form-select {
        width: 100%;
    }

    .question-diagram-box,
    .jsxgraph-diagram {
        min-height: 260px;
        height: 260px;
    }

    .sticky-submit-bar {
        bottom: 0.5rem;
        padding: 0.75rem;
    }

    .footer-signature-line {
        flex-direction: column;
        white-space: normal;
        text-align: center;
    }

    .mali-hero-actions {
        flex-direction: column;
    }

    .mali-hero-actions > .btn {
        width: 100%;
    }

    .footer-platform,
    .footer-owner-line {
        text-align: center;
        justify-content: center;
    }
}

@media print {
    body {
        background: #fff;
        margin-bottom: 0;
    }

    .lesson-toolbar {
        display: none !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        margin-bottom: 0 !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 h4,
    .d-flex.justify-content-between.align-items-center.mb-4 h5 {
        font-size: 0.9rem !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 img {
        height: 50px !important;
    }

    .lesson-title-label {
        font-size: 0.85rem !important;
        color: #333 !important;
    }

    .lesson-title-pill {
        border: 1px solid #4361ee !important;
        background: #4361ee !important;
        border-radius: 100px !important;
        padding: 0.3rem 30px !important;
        font-size: 1rem !important;
        color: #fff !important;
    }

    .lesson-plan-card .card-header .lesson-info-item {
        border: 1px solid #888 !important;
        background: #f5f5f5 !important;
        border-radius: 100px !important;
        padding: 0.15rem 0.6rem !important;
    }

    .lesson-plan-card .card-header .lesson-info-item .info-label,
    .lesson-plan-card .card-header .lesson-info-item .info-value {
        font-size: 0.78rem !important;
    }

    .navbar,
    .footer,
    .alert,
    .no-print {
        display: none !important;
    }

    .student-cards-grid {
        gap: 0.6rem;
    }

    .student-card-print {
        box-shadow: none;
        border: 1px solid #222;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mali-hero-backdrop,
    .mali-orbit,
    .mali-letter,
    main {
        animation: none !important;
    }

    .mali-letter {
        opacity: 1;
        filter: none;
    }

    .mali-letter-m {
        transform: translate(-144px, 0);
    }

    .mali-letter-a {
        transform: translate(-48px, 0);
    }

    .mali-letter-l {
        transform: translate(48px, 0);
    }

    .mali-letter-i {
        transform: translate(144px, 0);
    }
}

/* ===== Exam question navigation ===== */
.exam-radio-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.exam-option-btn {
    cursor: pointer;
    position: relative;
}

.exam-option-btn:has(input:checked) {
    border-color: var(--primary-color, #4361ee) !important;
    border-width: 3px !important;
    background: transparent !important;
    box-shadow: 0 0 0 2px var(--primary-color, #4361ee);
}

.exam-option-btn:has(input:checked)::after {
    content: '\2713';
    position: absolute;
    left: 16px;
    font-size: 18px;
    color: var(--primary-color, #4361ee);
    font-weight: 900;
}

html[data-theme="dark"] .exam-option-btn:has(input:checked) {
    border-color: #60a5fa !important;
    border-width: 3px !important;
    background: linear-gradient(180deg, #172033 0%, #101827 100%) !important;
    color: #f8fbff !important;
    box-shadow: 0 0 0 2px #60a5fa;
}

html[data-theme="dark"] .exam-option-btn:has(input:checked)::after {
    color: #60a5fa;
}

.exam-question-item .question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color, #4361ee);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 12px;
}

.exam-status-bar {
    display:flex;
    align-items:center;
    gap:12px;
    padding:6px 16px;
    background:rgba(220,38,38,0.08);
    border-bottom:1px solid rgba(220,38,38,0.12);
    flex-wrap:wrap;
}

.exam-timer {
    margin-left:auto;
    font-size:15px;
    font-weight:800;
    color:#dc2626;
    background:rgba(220,38,38,0.1);
    padding:4px 14px;
    border-radius:999px;
    direction:ltr;
    unicode-bidi:embed;
}

.exam-top-bar {
    display:flex;
    align-items:center;
    gap:12px;
    padding:8px 16px;
    background:transparent;
    position:sticky;
    top:0;
    z-index:50;
}

.exam-top-bar-center {
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    justify-content:center;
    gap:6px;
    flex:1;
}

.exam-top-bar-start,
.exam-top-bar-end {
    display:flex;
    align-items:center;
}

.exam-calc-icon-btn {
    display:flex;
    align-items:center;
    justify-content:center;
    width:40px;
    height:40px;
    border-radius:50%;
    border:2px solid #d1d5db;
    background:transparent;
    color:#6b7280;
    cursor:pointer;
    transition:var(--transition);
}

.exam-calc-icon-btn:hover {
    border-color:var(--primary-color);
    color:var(--primary-color);
}

.exam-qnav-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid #d1d5db;
    background: transparent;
    color: #6b7280;
    transition: var(--transition);
    user-select: none;
}

.exam-qnav-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid #d1d5db;
    background: transparent;
    color: #6b7280;
    transition: var(--transition);
    user-select: none;
}

.exam-qnav-circle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.exam-qnav-circle.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}

.exam-qnav-circle.answered {
    border-color: #10b981;
    background: #10b981;
    color: #fff;
}

.exam-qnav-circle.active.answered {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 0 2px #10b981;
}

html[data-theme="dark"] .exam-qnav-circle {
    border-color: #4b5563;
    color: #9ca3af;
}

html[data-theme="dark"] .exam-qnav-circle.answered {
    border-color: #059669;
    background: #059669;
    color: #fff;
}

html[data-theme="dark"] .exam-qnav-circle.active.answered {
    border-color: var(--primary-color);
    background: var(--primary-color);
    box-shadow: 0 0 0 2px #059669;
}

/* ===== Single question display ===== */
.exam-question-item {
    display: none;
}

.exam-question-item.active {
    display: block;
}

.exam-bottom-bar {
    display:flex;
    align-items:center;
    justify-content:space-between;
    position:sticky;
    bottom:0;
    padding:20px 32px calc(20px + env(safe-area-inset-bottom, 0px));
    background:transparent;
    z-index:50;
    margin-top:1.5rem;
    min-height:80px;
}

.exam-nav-arrow {
    display:flex;
    align-items:center;
    justify-content:center;
    width:48px;
    height:48px;
    border-radius:50%;
    border:none;
    background:#1e293b;
    color:#fff;
    cursor:pointer;
    box-shadow:0 2px 8px rgba(0,0,0,0.12);
    transition:var(--transition);
}

.exam-nav-arrow:hover {
    background:#0f172a;
    color:#fff;
    box-shadow:0 4px 14px rgba(0,0,0,0.18);
}

.exam-nav-arrow:disabled {
    opacity:0.3;
    cursor:default;
    background:#94a3b8;
    color:#f1f5f9;
}

html[data-theme="dark"] .exam-nav-arrow {
    background:#e2e8f0;
    color:#1e293b;
    box-shadow:0 2px 10px rgba(0,0,0,0.15);
}

html[data-theme="dark"] .exam-nav-arrow:hover {
    background:#f8fafc;
    color:#0f172a;
    box-shadow:0 4px 14px rgba(0,0,0,0.2);
}

.exam-submit-btn {
    padding:14px 40px;
    border-radius:999px;
    border:none;
    background:#10b981;
    color:#fff;
    font-weight:700;
    font-size:16px;
    cursor:pointer;
    transition:background 0.2s;
    min-height:52px;
}

.exam-submit-btn:hover {
    background:#059669;
}

.exam-calc-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 342px;
    z-index: 1050;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    direction: ltr;
}

.exam-calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #4361ee;
    color: #fff;
    border-radius: 11px 11px 0 0;
    cursor: move;
    font-size: 13px;
    font-weight: 700;
    direction: rtl;
    user-select: none;
}

.exam-calc-header .btn-close {
    font-size: 12px;
}

.exam-calc-body {
    padding: 0;
}

html[data-theme="dark"] .exam-calc-panel {
    background: #1f2937;
    border-color: #374151;
}

html[data-theme="dark"] .exam-calc-header {
    background: #1d4ed8;
}

/* ===== Diagram overlay (zoom + pan) ===== */
.exam-diagram-trigger {
    cursor: pointer;
    transition: opacity 0.2s;
}

.exam-diagram-trigger:hover {
    opacity: 0.85;
}

.exam-diagram-overlay {
    display:none;
    position:fixed;
    top:0;left:0;
    width:100vw;height:100vh;
    z-index:1060;
    background:rgba(0,0,0,0.85);
    flex-direction:column;
    align-items:stretch;
}

.exam-diagram-toolbar {
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 20px;
    background:#1e293b;
    color:#fff;
    flex-shrink:0;
}

.exam-diagram-title {
    font-weight:700;
    font-size:16px;
}

.exam-diagram-zoom-controls {
    display:flex;
    align-items:center;
    gap:10px;
}

.exam-diagram-zoom-btn {
    width:36px;height:36px;
    border-radius:50%;
    border:2px solid #fff;
    background:transparent;
    color:#fff;
    font-size:20px;
    font-weight:700;
    line-height:1;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    transition:background 0.2s;
}

.exam-diagram-zoom-btn:hover {
    background:rgba(255,255,255,0.2);
}

.exam-diagram-zoom-level {
    min-width:48px;
    text-align:center;
    font-size:14px;
    font-weight:600;
    direction:ltr;
}

.exam-diagram-close-btn {
    width:36px;height:36px;
    border-radius:50%;
    border:none;
    background:#ef4444;
    color:#fff;
    font-size:18px;
    font-weight:700;
    line-height:1;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    transition:background 0.2s;
}

.exam-diagram-close-btn:hover {
    background:#dc2626;
}

.exam-diagram-viewport {
    flex:1;
    overflow:hidden;
    display:flex;
    align-items:center;
    justify-content:center;
    position:relative;
    cursor:grab;
}

.exam-diagram-viewport:active {
    cursor:grabbing;
}

.exam-diagram-content {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    max-width:100%;
    max-height:100%;
    transform-origin:center center;
    transition:transform 0.05s linear;
    user-select:none;
    -webkit-user-select:none;
}

.exam-diagram-content img,
.exam-diagram-content svg {
    max-width:90vw;
    max-height:85vh;
    width:auto;
    height:auto;
    display:block;
    object-fit:contain;
}

.exam-diagram-content .jsxgraph-diagram {
    max-width:90vw;
    max-height:85vh;
    min-height:420px;
    width:auto;
    height:auto;
}

.exam-diagram-content .question-diagram-svg,
.exam-diagram-content .question-diagram-box {
    background:transparent;
    border:none;
    padding:0;
    margin:0;
    max-width:90vw;
    max-height:85vh;
    display:flex;
    align-items:center;
    justify-content:center;
}

.exam-diagram-content .question-diagram-svg svg {
    max-width:90vw;
    max-height:85vh;
    width:auto;
    height:auto;
}

@media (max-width: 768px) {
    .exam-qnav-circle {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }
}

/* ===== MALI text palette: blue, white, black only ===== */
:root {
    --mali-text-blue: #4361ee;
    --mali-text-black: #000000;
    --mali-text-white: #ffffff;
}

body,
.card,
.card-body,
.table tbody td,
.form-control,
.form-select,
.form-label,
.prompt-preview-box,
.ai-site-tile,
.ai-site-admin-item,
.footer-owner,
.footer-platform,
.footer-whatsapp,
.exam-option,
.exam-status-bar,
.exam-top-bar,
.exam-bottom-bar,
.exam-calc-panel,
.question-diagram-box,
.question-stem-surface,
.student-card-print {
    color: var(--mali-text-black);
}

h1, h2, h3, h4, h5, h6,
.card-header,
.mali-hero-eyebrow,
.mali-hero-tagline,
.mali-hero-subtitle,
.ai-site-name,
.navbar-brand,
.exam-timer,
.exam-qnav-circle,
.exam-calc-icon-btn,
.footer-whatsapp,
.footer-owner-line,
.text-danger,
.text-success,
.text-warning,
.text-info,
.alert-success,
.alert-warning,
.alert-info,
.alert-danger {
    color: var(--mali-text-blue) !important;
}

.text-muted,
.small.text-muted,
.form-text {
    color: var(--mali-text-black) !important;
}

.navbar,
.navbar .nav-link,
.navbar .navbar-brand,
.btn-primary,
.btn-success,
.btn-danger,
.btn-info,
.badge,
.ai-site-badge,
.exam-submit-btn,
.student-exam-launch-btn,
.student-exam-blackout,
.student-exam-blackout-title,
.student-exam-blackout-text,
.exam-diagram-toolbar,
.exam-diagram-zoom-btn,
.exam-diagram-close-btn,
.exam-question-item .question-number {
    color: var(--mali-text-white) !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.nav-tabs .nav-link {
    color: var(--mali-text-blue) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:active,
.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary,
.show > .btn-outline-primary.dropdown-toggle,
.btn-outline-secondary:hover,
.btn-outline-secondary:active,
.btn-outline-secondary.active,
.btn-check:checked + .btn-outline-secondary,
.btn-check:active + .btn-outline-secondary,
.show > .btn-outline-secondary.dropdown-toggle {
    color: #fff !important;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .prompt-preview-box,
html[data-theme="dark"] .ai-site-tile,
html[data-theme="dark"] .ai-site-admin-item,
html[data-theme="dark"] .exam-option,
html[data-theme="dark"] .exam-status-bar,
html[data-theme="dark"] .exam-top-bar,
html[data-theme="dark"] .exam-bottom-bar,
html[data-theme="dark"] .exam-calc-panel,
html[data-theme="dark"] .footer-owner,
html[data-theme="dark"] .footer-platform {
    color: var(--mali-text-white);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .text-danger,
html[data-theme="dark"] .text-success,
html[data-theme="dark"] .text-warning,
html[data-theme="dark"] .text-info,
html[data-theme="dark"] .alert-success,
html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .exam-timer,
html[data-theme="dark"] .exam-qnav-circle,
html[data-theme="dark"] .exam-calc-icon-btn {
    color: var(--mali-text-blue) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .small.text-muted,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] code,
html[data-theme="dark"] .table code {
    color: var(--mali-text-white) !important;
}

.form-control::placeholder,
.form-select::placeholder,
textarea::placeholder {
    color: rgba(0, 0, 0, 0.55) !important;
    opacity: 1;
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-select::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: rgba(255, 255, 255, 0.72) !important;
    opacity: 1;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

/* ===== Final dark surface cleanup ===== */
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .table-responsive.border,
html[data-theme="dark"] .table-striped,
html[data-theme="dark"] .table-hover,
html[data-theme="dark"] .student-card-print,
html[data-theme="dark"] .student-card-body,
html[data-theme="dark"] .admin-form-card,
html[data-theme="dark"] .school-admin-card,
html[data-theme="dark"] .ai-site-admin-item {
    background-color: #0f172a !important;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
html[data-theme="dark"] .card .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #131d31 !important;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(even) > *,
html[data-theme="dark"] .card .table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: #0f172a !important;
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .card .table thead th,
html[data-theme="dark"] .table-responsive .table thead th {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a) !important;
    color: #e0f2fe !important;
}

html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .card .table tbody td,
html[data-theme="dark"] .table-responsive .table tbody td {
    color: #e2e8f0 !important;
    border-bottom-color: #1e293b !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select {
    background-color: #111827 !important;
    border-color: #374151 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
}

html[data-theme="dark"] select option {
    background-color: #1f2937;
    color: #ffffff;
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill:hover,
html[data-theme="dark"] textarea:-webkit-autofill:focus,
html[data-theme="dark"] select:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill:hover,
html[data-theme="dark"] select:-webkit-autofill:focus {
    -webkit-text-fill-color: #ffffff !important;
    caret-color: #ffffff !important;
    -webkit-box-shadow: 0 0 0 1000px #111827 inset !important;
    box-shadow: 0 0 0 1000px #111827 inset !important;
    border-color: #374151 !important;
    transition: background-color 9999s ease-out 0s;
}

html[data-theme="dark"] .alert-info {
    background-color: #0f2747 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .alert-warning {
    background-color: #4a3412 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .alert-success {
    background-color: #0f5132 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .alert-danger {
    background-color: #5b1f29 !important;
    color: #ffffff !important;
}

/* ===== Final internal page contrast audit ===== */
body:not(.page-with-bg) .card,
body:not(.page-with-bg) .card-body,
body:not(.page-with-bg) .list-group-item,
body:not(.page-with-bg) .table-responsive,
body:not(.page-with-bg) .table-responsive.border,
body:not(.page-with-bg) .alert,
body:not(.page-with-bg) .form-control,
body:not(.page-with-bg) .form-select,
body:not(.page-with-bg) textarea,
body:not(.page-with-bg) .footer {
    color: #0f172a !important;
}

body:not(.page-with-bg) .card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-color: rgba(67, 97, 238, 0.16);
}

body:not(.page-with-bg) .card-header,
body:not(.page-with-bg) .card-footer {
    background: linear-gradient(180deg, #eff5ff 0%, #e6eefc 100%);
    color: #173569 !important;
    border-color: rgba(67, 97, 238, 0.18);
}

body:not(.page-with-bg) .list-group-item {
    background-color: #ffffff;
    border-color: rgba(67, 97, 238, 0.16);
}

body:not(.page-with-bg) .text-muted,
body:not(.page-with-bg) .small.text-muted,
body:not(.page-with-bg) .form-text,
body:not(.page-with-bg) .footer.text-muted,
body:not(.page-with-bg) footer.text-muted {
    color: #334155 !important;
}

body:not(.page-with-bg) .form-control,
body:not(.page-with-bg) .form-select,
body:not(.page-with-bg) textarea {
    background-color: #ffffff;
    border-color: #94a3b8;
}

body:not(.page-with-bg) .form-control:focus,
body:not(.page-with-bg) .form-select:focus,
body:not(.page-with-bg) textarea:focus {
    background-color: #ffffff;
    color: #0f172a !important;
    border-color: #4361ee;
}

body:not(.page-with-bg) .alert-info {
    background-color: #e0f2fe !important;
    border-color: #7dd3fc !important;
    color: #0c4a6e !important;
}

body:not(.page-with-bg) .alert-warning {
    background-color: #fef3c7 !important;
    border-color: #fbbf24 !important;
    color: #78350f !important;
}

body:not(.page-with-bg) .alert-success {
    background-color: #dcfce7 !important;
    border-color: #4ade80 !important;
    color: #166534 !important;
}

body:not(.page-with-bg) .alert-danger {
    background-color: #fee2e2 !important;
    border-color: #f87171 !important;
    color: #991b1b !important;
}

body:not(.page-with-bg) .badge.text-bg-light,
body:not(.page-with-bg) .badge.bg-light,
body:not(.page-with-bg) .badge.bg-secondary-subtle,
body:not(.page-with-bg) .badge.bg-success-subtle,
body:not(.page-with-bg) .badge.bg-info-subtle,
body:not(.page-with-bg) .badge.bg-warning-subtle,
body:not(.page-with-bg) .badge.bg-danger-subtle {
    color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.16);
}

body:not(.page-with-bg) .badge.text-bg-light,
body:not(.page-with-bg) .badge.bg-light {
    background-color: #e2e8f0 !important;
}

body:not(.page-with-bg) .badge.bg-secondary-subtle {
    background-color: #dbe4f3 !important;
}

body:not(.page-with-bg) .badge.bg-success-subtle {
    background-color: #dcfce7 !important;
}

body:not(.page-with-bg) .badge.bg-info-subtle {
    background-color: #dbeafe !important;
}

body:not(.page-with-bg) .badge.bg-warning-subtle {
    background-color: #fef3c7 !important;
}

body:not(.page-with-bg) .badge.bg-danger-subtle {
    background-color: #fee2e2 !important;
}

body:not(.page-with-bg) .badge.text-success-emphasis,
body:not(.page-with-bg) .badge.text-info-emphasis,
body:not(.page-with-bg) .badge.text-warning-emphasis,
body:not(.page-with-bg) .badge.text-danger-emphasis,
body:not(.page-with-bg) .badge.text-secondary-emphasis,
body:not(.page-with-bg) .badge.text-dark,
body:not(.page-with-bg) .text-dark {
    color: #0f172a !important;
}

html[data-theme="dark"] .bg-success-subtle,
html[data-theme="dark"] .bg-info-subtle,
html[data-theme="dark"] .bg-warning-subtle,
html[data-theme="dark"] .bg-danger-subtle {
    background-color: #1e293b !important;
}

html[data-theme="dark"] .text-success-emphasis,
html[data-theme="dark"] .text-info-emphasis,
html[data-theme="dark"] .text-warning-emphasis,
html[data-theme="dark"] .text-danger-emphasis {
    color: #ffffff !important;
}

html[data-theme="dark"] .test-preview-page.exam-wrapper {
    background:
        radial-gradient(circle at top right, rgba(67, 97, 238, 0.16), transparent 28%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #ffffff;
}

html[data-theme="dark"] body:not(.page-with-bg) .card,
html[data-theme="dark"] body:not(.page-with-bg) .card-body,
html[data-theme="dark"] body:not(.page-with-bg) .list-group-item,
html[data-theme="dark"] body:not(.page-with-bg) .table-responsive,
html[data-theme="dark"] body:not(.page-with-bg) .table-responsive.border,
html[data-theme="dark"] body:not(.page-with-bg) .footer {
    background-color: #1f2937 !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .card {
    border-color: #334155 !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .card-header,
html[data-theme="dark"] body:not(.page-with-bg) .card-footer {
    background: linear-gradient(180deg, #22314a 0%, #1e293b 100%) !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .list-group-item {
    border-color: #334155 !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .text-muted,
html[data-theme="dark"] body:not(.page-with-bg) .small.text-muted,
html[data-theme="dark"] body:not(.page-with-bg) .form-text,
html[data-theme="dark"] body:not(.page-with-bg) .footer.text-muted,
html[data-theme="dark"] body:not(.page-with-bg) footer.text-muted {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .badge.text-bg-light,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-light,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-secondary-subtle,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-success-subtle,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-info-subtle,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-warning-subtle,
html[data-theme="dark"] body:not(.page-with-bg) .badge.bg-danger-subtle {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-color: rgba(148, 163, 184, 0.4) !important;
}

html[data-theme="dark"] body:not(.page-with-bg) .badge.text-success-emphasis,
html[data-theme="dark"] body:not(.page-with-bg) .badge.text-info-emphasis,
html[data-theme="dark"] body:not(.page-with-bg) .badge.text-warning-emphasis,
html[data-theme="dark"] body:not(.page-with-bg) .badge.text-danger-emphasis,
html[data-theme="dark"] body:not(.page-with-bg) .badge.text-secondary-emphasis,
html[data-theme="dark"] body:not(.page-with-bg) .badge.text-dark,
html[data-theme="dark"] body:not(.page-with-bg) .text-dark {
    color: #f8fafc !important;
}

html[data-theme="dark"] .test-preview-page .exam-header h1,
html[data-theme="dark"] .test-preview-page .exam-meta,
html[data-theme="dark"] .test-preview-page .form-label,
html[data-theme="dark"] .test-preview-page #selectedStudent {
    color: #ffffff !important;
}

html[data-theme="dark"] .test-preview-page .questions-container,
html[data-theme="dark"] .test-preview-page .quiz-card {
    background: #111827 !important;
    border-color: #334155 !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] .test-preview-page .question-stem-surface,
html[data-theme="dark"] .test-preview-page .question-text,
html[data-theme="dark"] .test-preview-page .question-text-panel,
html[data-theme="dark"] .test-preview-page .question-body-layout,
html[data-theme="dark"] .test-preview-page .graph,
html[data-theme="dark"] .test-preview-page .graph-box {
    background: #182234 !important;
    color: #ffffff !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .question-diagram-box,
html[data-theme="dark"] .jsxgraph-diagram,
html[data-theme="dark"] .question-diagram-svg,
html[data-theme="dark"] .test-preview-page .question-diagram-box,
html[data-theme="dark"] .test-preview-page .question-diagram-svg {
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%) !important;
    color: initial !important;
    border-color: rgba(67, 97, 238, 0.18) !important;
}

html[data-theme="dark"] .test-preview-page .question-stem-copy,
html[data-theme="dark"] .test-preview-page .question-meta,
html[data-theme="dark"] .test-preview-page .question-meta .text-muted,
html[data-theme="dark"] .test-preview-page .question-meta span,
html[data-theme="dark"] .test-preview-page .question-text p,
html[data-theme="dark"] .test-preview-page .question-number {
    color: #ffffff !important;
}

html[data-theme="dark"] .test-preview-page .options-list {
    background: transparent !important;
}

html[data-theme="dark"] .test-preview-page .option-btn {
    background: #182234 !important;
    color: #ffffff !important;
    border-color: #60a5fa !important;
    box-shadow: none;
}

html[data-theme="dark"] .test-preview-page .option-btn:hover:not(.disabled) {
    background: #1e293b !important;
    color: #ffffff !important;
    border-color: #93c5fd !important;
}

html[data-theme="dark"] .test-preview-page .option-btn.correct-ans {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(34, 197, 94, 0.16)) !important;
    color: #ffffff !important;
    border-color: #22c55e !important;
}

html[data-theme="dark"] .test-preview-page .option-btn.incorrect-ans {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.24), rgba(220, 38, 38, 0.16)) !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

html[data-theme="dark"] .test-preview-page .badge.bg-secondary {
    background-color: #334155 !important;
    color: #ffffff !important;
}

.test-preview-page.exam-wrapper {
    width: 100vw;
    max-width: 100vw;
    margin-inline: calc(50% - 50vw);
    padding-inline: clamp(1rem, 2vw, 2rem);
}

.test-preview-page .questions-container {
    max-width: 100%;
    width: 100%;
    margin-inline: auto;
}

.test-preview-page .quiz-card {
    width: 100%;
    max-width: none;
}

.test-preview-page .question-body-layout.has-diagram {
    grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.4fr);
    align-items: start;
    gap: 1.5rem;
}

.test-preview-page .question-text-panel,
.test-preview-page .question-visual-panel {
    min-width: 0;
}

.test-preview-page .question-stem-surface {
    min-height: 100%;
}

@media (min-width: 1400px) {
    .test-preview-page .question-body-layout.has-diagram {
        grid-template-columns: minmax(360px, 0.85fr) minmax(700px, 1.55fr);
    }
}

@media (max-width: 991.98px) {
    .test-preview-page.exam-wrapper,
    .test-preview-page .questions-container {
        max-width: 100%;
    }

    .test-preview-page .question-body-layout.has-diagram {
        grid-template-columns: 1fr;
    }
}

html[data-theme="dark"] .classes-students-table,
html[data-theme="dark"] .classes-search-table,
html[data-theme="dark"] .classes-index-table {
    background-color: #1f2937 !important;
    border-radius: 0 0 16px 16px;
}

html[data-theme="dark"] .classes-students-table .table,
html[data-theme="dark"] .classes-search-table .table,
html[data-theme="dark"] .classes-index-table .table,
html[data-theme="dark"] .classes-students-table .table tbody,
html[data-theme="dark"] .classes-search-table .table tbody,
html[data-theme="dark"] .classes-index-table .table tbody {
    background-color: #1f2937 !important;
}

html[data-theme="dark"] .classes-students-table .table thead th,
html[data-theme="dark"] .classes-search-table .table thead th,
html[data-theme="dark"] .classes-index-table .table thead th {
    background: linear-gradient(135deg, #1e3a5f, #1a2d4a) !important;
    color: #e0f2fe !important;
}

html[data-theme="dark"] .classes-students-table .table tbody tr:nth-of-type(odd) > *,
html[data-theme="dark"] .classes-search-table .table tbody tr:nth-of-type(odd) > *,
html[data-theme="dark"] .classes-index-table .table tbody tr:nth-of-type(odd) > * {
    background-color: #131d31 !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .classes-students-table .table tbody tr:nth-of-type(even) > *,
html[data-theme="dark"] .classes-search-table .table tbody tr:nth-of-type(even) > *,
html[data-theme="dark"] .classes-index-table .table tbody tr:nth-of-type(even) > * {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] .classes-students-table .text-muted,
html[data-theme="dark"] .classes-search-table .text-muted,
html[data-theme="dark"] .classes-index-table .text-muted,
html[data-theme="dark"] .classes-students-table .small.text-muted,
html[data-theme="dark"] .classes-search-table .small.text-muted,
html[data-theme="dark"] .classes-index-table .small.text-muted {
    color: #e5e7eb !important;
}

.score-report-table .table {
    min-width: max-content;
}

.report-test-col {
    min-width: 220px;
    vertical-align: top;
}

.report-test-head {
    min-width: 200px;
}

.report-sticky-col,
.report-sticky-col-second {
    position: sticky;
    background: inherit;
    z-index: 2;
}

.report-sticky-col {
    inset-inline-start: 0;
    min-width: 120px;
}

.report-sticky-col-second {
    inset-inline-start: 120px;
    min-width: 220px;
}

.score-report-table thead .report-sticky-col,
.score-report-table thead .report-sticky-col-second {
    z-index: 4;
}

.report-score-cell {
    min-width: 110px;
    padding: 0.7rem 0.75rem;
    border-radius: 14px;
    text-align: center;
    background: #eff6ff;
    border: 1px solid rgba(67, 97, 238, 0.12);
}

.report-score-cell.pending {
    background: #fff7ed;
    border-color: rgba(234, 88, 12, 0.18);
    color: #9a3412;
}

.report-score-cell.submitted {
    background: #ecfeff;
    border-color: rgba(8, 145, 178, 0.18);
    color: #155e75;
}

.report-score-cell.not-assigned {
    background: #f3f4f6;
    border-color: rgba(107, 114, 128, 0.12);
    color: #6b7280;
}

.analysis-question-card {
    margin-bottom: 0;
}

.analysis-question-text {
    line-height: 1.8;
}

.analysis-correctness-pill {
    min-width: 160px;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.12), rgba(63, 55, 201, 0.08));
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
}

.analysis-correctness-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--secondary-color);
}

.analysis-correctness-label {
    font-size: 0.9rem;
    color: #4b5563;
}

.analysis-mini-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid rgba(67, 97, 238, 0.08);
}

.analysis-mini-label {
    font-size: 0.9rem;
    color: #6b7280;
}

.analysis-mini-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.analysis-correct-choice-row > * {
    background-color: rgba(34, 197, 94, 0.08) !important;
}

html[data-theme="dark"] .report-score-cell {
    background: #162235;
    border-color: rgba(96, 165, 250, 0.18);
    color: #f8fafc;
}

html[data-theme="dark"] .report-score-cell.pending {
    background: #422b12;
    border-color: rgba(251, 146, 60, 0.22);
    color: #fed7aa;
}

html[data-theme="dark"] .report-score-cell.submitted {
    background: #12303a;
    border-color: rgba(34, 211, 238, 0.22);
    color: #cffafe;
}

html[data-theme="dark"] .report-score-cell.not-assigned {
    background: #1f2937;
    border-color: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
}

html[data-theme="dark"] .analysis-correctness-pill,
html[data-theme="dark"] .analysis-mini-stat {
    background: #162235;
    border-color: rgba(96, 165, 250, 0.16);
}

html[data-theme="dark"] .analysis-correctness-label,
html[data-theme="dark"] .analysis-mini-label {
    color: #cbd5e1;
}

html[data-theme="dark"] .analysis-correct-choice-row > * {
    background-color: rgba(34, 197, 94, 0.14) !important;
}

/* ==============================================
   LESSON PLANS — Modern Styling
   ============================================== */

/* Modern font assignments */
.lesson-plan-page {
    font-family: 'Tajawal', sans-serif;
}

.lesson-plan-page h1,
.lesson-plan-page h2,
.lesson-plan-page h3,
.lesson-plan-page h4,
.lesson-plan-page h5,
.lesson-plan-page h6,
.lesson-plan-page .card-header {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    letter-spacing: -0.02em;
}

.lesson-plan-page .lesson-arabic-text {
    font-family: 'Tajawal', sans-serif;
    line-height: 1.9;
}

.lesson-plan-page .lesson-modern-label {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Lesson Plan Table — Inside Details ===== */
.lesson-plan-table-wrap {
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 2px 0 rgba(67, 97, 238, 0.06),
        0 8px 24px rgba(0, 0, 0, 0.04);
    border: 1px solid #000;
    margin-bottom: 1.5rem;
    transition: box-shadow 0.3s ease;
}

.lesson-plan-table-wrap:hover {
    box-shadow:
        0 2px 0 rgba(67, 97, 238, 0.10),
        0 12px 32px rgba(0, 0, 0, 0.06);
}

.lesson-plan-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    table-layout: fixed;
}

.lesson-plan-table thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 1rem 1mm;
    border: 1px solid #000;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lesson-plan-table tbody td {
    padding: 0.9rem 1mm;
    vertical-align: middle;
    border: 1px solid #000;
    background-color: #ffffff;
    color: #1e293b;
    font-size: 0.95rem;
    line-height: 1.6;
}

.lesson-plan-table tbody tr:nth-child(even) td {
    background-color: #fafcff;
}

.lesson-plan-table tbody tr:hover td {
    background-color: #eef5ff;
}

/* ===== Scenario Table specific ===== */
.lesson-plan-table .col-time { width: 6%; text-align: center; }
.lesson-plan-table .col-outcome { width: 14.13%; }
.lesson-plan-table .col-method { width: 8%; }
.lesson-plan-table .col-teacher-role { width: 27.21%; }
.lesson-plan-table .col-student-role { width: 27.21%; }
.lesson-plan-table .col-assessment { width: 8%; }
.lesson-plan-table .col-activities { width: 9.45%; }

/* Seq number badge */
.lesson-plan-table .seq-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4361ee, #3f37c9);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.20);
}

/* Time pill */
.lesson-plan-table .time-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid rgba(67, 97, 238, 0.15);
}

.lesson-plan-table tbody td:first-child {
    text-align: start;
}

.lesson-outcome-cell {
    vertical-align: top !important;
}

.lesson-outcome-seq {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.35rem;
}

.lesson-outcome-text {
    text-align: start;
}

/* Steps ordered list styling */
.lesson-plan-table .steps-list {
    margin: 0;
    padding-inline-start: 1.2rem;
    list-style: none;
    counter-reset: step-counter;
}

.lesson-plan-table .steps-list li {
    counter-increment: step-counter;
    position: relative;
    padding-inline-start: 1.6rem;
    margin-bottom: 0.4rem;
    line-height: 1.7;
    font-size: 0.92rem;
}

.lesson-plan-table .steps-list li::before {
    content: counter(step-counter);
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(67, 97, 238, 0.10);
    color: #4361ee;
    font-size: 0.7rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lesson-plan-table .steps-list li:last-child {
    margin-bottom: 0;
}

/* Language-aware alignment for steps and outcome cells */
.lesson-steps-cell {
    text-align: start;
}

.scenario-table th,
.scenario-table td {
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}

.scenario-table td .steps-list {
    margin-top: 0.15rem;
}



/* ===== Lesson Plan Cards ===== */
.lesson-plan-card {
    border: none;
    border-radius: 20px;
    background: #ffffff;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 4px 16px rgba(67, 97, 238, 0.06);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin-bottom: 1.8rem;
    overflow: hidden;
}

.lesson-plan-card:hover {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 8px 28px rgba(67, 97, 238, 0.10);
    transform: translateY(-2px);
}

/* ===== Grade pills on Index ===== */
.lesson-grade-pills {
    margin-top: -0.5rem;
}

.grade-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    border: 2px solid rgba(67, 97, 238, 0.20);
    background: #ffffff;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.grade-pill:hover {
    border-color: rgba(67, 97, 238, 0.40);
    background: #f0f4ff;
    text-decoration: none;
}

.grade-pill.active {
    border-color: #4361ee;
    background: #4361ee;
}

.grade-pill.active .grade-pill-name {
    color: #fff;
}

.grade-pill.active .grade-pill-count {
    background: rgba(255, 255, 255, 0.20);
    color: #fff;
}

.grade-pill-name {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
}

.grade-pill-count {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    color: #4361ee;
    background: rgba(67, 97, 238, 0.10);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
}

.lesson-plan-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(67, 97, 238, 0.08);
    padding: 1.3rem 1.5rem;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.lesson-plan-card .card-body {
    padding: 1.3rem 1.5rem;
}

/* ===== Lesson Plan Info Grid ===== */
.lesson-info-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.lesson-info-item {
    flex: 1 0 auto;
    min-width: 80px;
    max-width: 100%;
    white-space: nowrap;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    border-radius: 100px;
    background: #f8fafc;
    border: 2px solid rgba(67, 97, 238, 0.35);
    transition: all 0.2s ease;
}

.lesson-info-item:hover {
    background: #eef5ff;
    border-color: rgba(67, 97, 238, 0.55);
}

.lesson-info-item .info-label {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.lesson-info-item .info-value {
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

/* ===== Title label & pill ===== */
.lesson-title-label {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
}

.lesson-title-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 0.35rem 50px;
    border-radius: 100px;
    border: 2px solid rgba(67, 97, 238, 0.35);
    background: #4361ee;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
}

/* ===== Toolbar ===== */
.lesson-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.9rem 1.2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.70);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(67, 97, 238, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.lesson-toolbar h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Index Table ===== */
.lesson-index-table {
    width: 100%;
    border-collapse: collapse;
}

.lesson-index-table thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.9rem 1rem;
    border: 1px solid #000;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lesson-index-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border: 1px solid #000;
    background: #ffffff;
    color: #1e293b;
    font-size: 0.92rem;
}

.lesson-index-table tbody tr:nth-child(even) td {
    background: #fafcff;
}

.lesson-index-table tbody tr:hover td {
    background: #eef5ff;
}

/* ===== Form elements inside lesson plans ===== */
.lesson-plan-page .form-control,
.lesson-plan-page .form-select {
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
    padding: 0.7rem 1rem;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    background: #ffffff;
}

.lesson-plan-page .form-control:focus,
.lesson-plan-page .form-select:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
    background: #ffffff;
}

.lesson-plan-page .form-label {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

/* ===== Section divider with gradient ===== */
.lesson-section-divider {
    position: relative;
    margin: 2rem 0 1.5rem;
    padding: 0.6rem 0;
    text-align: center;
}

.lesson-section-divider::before {
    content: '';
    position: absolute;
    inset: 50% 0 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(67, 97, 238, 0.20), transparent);
}

.lesson-section-divider span {
    position: relative;
    z-index: 1;
    background: var(--bg-color, #f4f7f6);
    padding: 0 1.2rem;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    color: #4361ee;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ===== Motivation card - single line ===== */
.lesson-motivation-card .card-body {
    padding: 0.85rem 1.2rem;
}

.lesson-motivation-title {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 800;
    font-size: 0.88rem;
    color: #b45309;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(234, 179, 8, 0.25);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.lesson-motivation-text {
    font-size: 1.02rem;
    line-height: 1.6;
    color: #713f12;
    flex: 1;
    min-width: 0;
}

/* ===== Skills & Links grid ===== */
.lesson-skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.lesson-skill-box {
    padding: 1.2rem 1.3rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(67, 97, 238, 0.30);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.02),
        0 8px 24px rgba(67, 97, 238, 0.08);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.lesson-skill-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4361ee, #3f37c9, #4361ee);
    background-size: 200% 100%;
    animation: skillShimmer 3s ease-in-out infinite;
}

@keyframes skillShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.lesson-skill-box:hover {
    transform: translateY(-3px);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.03),
        0 16px 40px rgba(67, 97, 238, 0.12);
    border-color: rgba(67, 97, 238, 0.45);
    background: linear-gradient(135deg, #ffffff 0%, #eef5ff 100%);
}

.lesson-skill-box strong {
    display: block;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-size: 0.78rem;
    color: #4361ee;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}

/* ===== Teacher signature ===== */
.lesson-teacher-signature {
    text-align: center;
    padding: 1.5rem;
    margin-top: 1.5rem;
    border-top: 2px dashed rgba(67, 97, 238, 0.12);
    font-family: 'Tajawal', sans-serif;
    font-size: 1.05rem;
    color: #475569;
}

/* ===== Dark mode compatibility ===== */
html[data-theme="dark"] .lesson-plan-table-wrap {
    border-color: #fff;
    background: #1f2937;
}

html[data-theme="dark"] .lesson-plan-table thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #fff;
}

html[data-theme="dark"] .lesson-plan-table tbody td {
    background-color: #1f2937;
    color: #f1f5f9;
    border-color: #fff;
}

html[data-theme="dark"] .lesson-plan-table tbody tr:nth-child(even) td {
    background-color: #182234;
}

html[data-theme="dark"] .lesson-plan-table tbody tr:hover td {
    background-color: #1e293b;
}

html[data-theme="dark"] .lesson-plan-table .time-pill {
    background: rgba(96, 165, 250, 0.12);
    color: #93c5fd;
    border-color: rgba(96, 165, 250, 0.15);
}

html[data-theme="dark"] .lesson-plan-card {
    background: #1f2937;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
}

html[data-theme="dark"] .lesson-plan-card .card-header {
    border-bottom-color: rgba(96, 165, 250, 0.10);
    color: #93c5fd;
}

html[data-theme="dark"] .grade-pill {
    background: #1f2937;
    border-color: rgba(96, 165, 250, 0.20);
}

html[data-theme="dark"] .grade-pill:hover {
    border-color: rgba(96, 165, 250, 0.40);
    background: #182234;
}

html[data-theme="dark"] .grade-pill.active {
    background: #4361ee;
    border-color: #4361ee;
}

html[data-theme="dark"] .grade-pill-name {
    color: #f1f5f9;
}

html[data-theme="dark"] .grade-pill.active .grade-pill-name {
    color: #fff;
}

html[data-theme="dark"] .grade-pill-count {
    background: rgba(96, 165, 250, 0.15);
    color: #93c5fd;
}

html[data-theme="dark"] .grade-pill.active .grade-pill-count {
    background: rgba(255, 255, 255, 0.20);
    color: #fff;
}

html[data-theme="dark"] .lesson-info-item {
    background: #182234;
    border-color: rgba(96, 165, 250, 0.30);
}

html[data-theme="dark"] .lesson-info-item:hover {
    background: #1e293b;
    border-color: rgba(96, 165, 250, 0.50);
}

html[data-theme="dark"] .lesson-info-item .info-label {
    color: #94a3b8;
}

html[data-theme="dark"] .lesson-info-item .info-value {
    color: #f1f5f9;
}

html[data-theme="dark"] .lesson-toolbar {
    background: rgba(31, 41, 55, 0.70);
    border-color: rgba(96, 165, 250, 0.08);
}

html[data-theme="dark"] .lesson-toolbar h1 {
    color: #93c5fd;
}

html[data-theme="dark"] .lesson-plan-page .form-control,
html[data-theme="dark"] .lesson-plan-page .form-select {
    background: #111827;
    border-color: #374151;
    color: #f1f5f9;
}

html[data-theme="dark"] .lesson-plan-page .form-control:focus,
html[data-theme="dark"] .lesson-plan-page .form-select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
    background: #111827;
}

html[data-theme="dark"] .lesson-plan-page .form-label {
    color: #94a3b8;
}

html[data-theme="dark"] .lesson-motivation-title {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.20) 0%, rgba(234, 179, 8, 0.12) 100%);
    color: #fde68a;
    border-color: rgba(234, 179, 8, 0.20);
}

html[data-theme="dark"] .lesson-motivation-text {
    color: #fde68a;
}

html[data-theme="dark"] .lesson-skill-box {
    background: linear-gradient(135deg, #1f2937 0%, #182234 100%);
    border-color: rgba(96, 165, 250, 0.25);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.20);
}

html[data-theme="dark"] .lesson-skill-box:hover {
    background: linear-gradient(135deg, #22314a 0%, #1e293b 100%);
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.18), 0 16px 40px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .lesson-skill-box strong {
    color: #93c5fd;
}

html[data-theme="dark"] .lesson-teacher-signature {
    border-top-color: rgba(96, 165, 250, 0.10);
    color: #94a3b8;
}

html[data-theme="dark"] .lesson-index-table tbody td {
    background: #1f2937;
    color: #f1f5f9;
    border-color: #fff;
}

html[data-theme="dark"] .lesson-index-table tbody tr:nth-child(even) td {
    background: #182234;
}

html[data-theme="dark"] .lesson-index-table tbody tr:hover td {
    background: #1e293b;
}

html[data-theme="dark"] .lesson-index-table thead th {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    border-color: #fff;
}

html[data-theme="dark"] .lesson-section-divider span {
    background: #111827;
    color: #93c5fd;
}

html[data-theme="dark"] .lesson-plan-table .steps-list li::before {
    background: rgba(96, 165, 250, 0.12);
    color: #93c5fd;
}

html[data-theme="dark"] .lesson-plan-table .seq-badge {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

/* Unified dark surfaces for Bootstrap and page-specific components. */
@media screen {
    html[data-theme="dark"] {
        color-scheme: dark;
    }

    html[data-theme="dark"] .modal-content,
    html[data-theme="dark"] .offcanvas,
    html[data-theme="dark"] .dropdown-menu,
    html[data-theme="dark"] .list-group-item,
    html[data-theme="dark"] .accordion-item,
    html[data-theme="dark"] .accordion-button,
    html[data-theme="dark"] .popover,
    html[data-theme="dark"] .toast,
    html[data-theme="dark"] details,
    html[data-theme="dark"] .input-group-text,
    html[data-theme="dark"] .page-link {
        color: var(--text-color);
        background-color: var(--surface-elevated);
        border-color: var(--surface-border);
    }

    html[data-theme="dark"] .modal-header,
    html[data-theme="dark"] .modal-footer,
    html[data-theme="dark"] .offcanvas-header,
    html[data-theme="dark"] .dropdown-divider,
    html[data-theme="dark"] details > summary {
        border-color: var(--surface-border);
    }

    html[data-theme="dark"] .dropdown-item,
    html[data-theme="dark"] .list-group-item-action,
    html[data-theme="dark"] .accordion-button,
    html[data-theme="dark"] .breadcrumb-item,
    html[data-theme="dark"] .breadcrumb-item a,
    html[data-theme="dark"] .page-link {
        color: #e2e8f0;
    }

    html[data-theme="dark"] .dropdown-item:hover,
    html[data-theme="dark"] .dropdown-item:focus,
    html[data-theme="dark"] .list-group-item-action:hover,
    html[data-theme="dark"] .list-group-item-action:focus,
    html[data-theme="dark"] .accordion-button:not(.collapsed),
    html[data-theme="dark"] .page-link:hover,
    html[data-theme="dark"] .page-link:focus {
        color: #ffffff;
        background-color: var(--surface-hover);
    }

    html[data-theme="dark"] .modal-title,
    html[data-theme="dark"] .offcanvas-title,
    html[data-theme="dark"] h1,
    html[data-theme="dark"] h2,
    html[data-theme="dark"] h3,
    html[data-theme="dark"] h4,
    html[data-theme="dark"] h5,
    html[data-theme="dark"] h6,
    html[data-theme="dark"] legend {
        color: #f8fafc;
    }

    html[data-theme="dark"] .bg-white,
    html[data-theme="dark"] .bg-light,
    html[data-theme="dark"] .bg-body,
    html[data-theme="dark"] .bg-body-tertiary,
    html[data-theme="dark"] .alert-light {
        color: var(--text-color) !important;
        background-color: var(--surface-bg) !important;
        border-color: var(--surface-border) !important;
    }

    html[data-theme="dark"] .text-dark,
    html[data-theme="dark"] .text-body,
    html[data-theme="dark"] .text-body-emphasis {
        color: var(--text-color) !important;
    }

    html[data-theme="dark"] .border,
    html[data-theme="dark"] .border-top,
    html[data-theme="dark"] .border-bottom,
    html[data-theme="dark"] .border-start,
    html[data-theme="dark"] .border-end {
        border-color: var(--surface-border) !important;
    }

    html[data-theme="dark"] .form-control::placeholder,
    html[data-theme="dark"] textarea::placeholder {
        color: #94a3b8;
        opacity: 1;
    }

    html[data-theme="dark"] .form-select option {
        color: #f1f5f9;
        background-color: #111827;
    }

    html[data-theme="dark"] .btn-close {
        filter: invert(1) grayscale(100%) brightness(180%);
    }

    html[data-theme="dark"] .admin-stat-card,
    html[data-theme="dark"] .school-admin-card,
    html[data-theme="dark"] .subject-prompt-panel,
    html[data-theme="dark"] .ai-site-admin-item,
    html[data-theme="dark"] .prompt-card,
    html[data-theme="dark"] .generator-card,
    html[data-theme="dark"] .filter-card,
    html[data-theme="dark"] .assignment-card {
        color: var(--text-color);
        background: var(--surface-elevated);
        border-color: var(--surface-border);
    }
}
