*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-deep: #f1f5f9;
  --surface: rgba(255, 255, 255, 0.95);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #60a5fa;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-glow: rgba(37, 99, 235, 0.25);
  --violet: #1e40af;
  --sky: #2563eb;
  --emerald: #059669;
  --amber: #d97706;
  --rose: #2563eb;
  --border: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.12);
  --radius: 1.1rem;
  --radius-lg: 1.35rem;
  --sidebar-width: 270px;
  --topbar-height: 68px;
  font-family: "Tajawal", system-ui, sans-serif;
  line-height: 1.65;
}

html {
  scroll-behavior: smooth;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 70% at 100% -10%, rgba(37, 99, 235, 0.06), transparent 55%),
    radial-gradient(ellipse 80% 60% at -5% 105%, rgba(217, 119, 6, 0.04), transparent 50%);
  color: var(--text);
}

/* ── السماح الكامل بالتحديد والنسخ في لوحة الإدارة ── */
body[data-page="admin"],
body[data-page="admin"] *,
.admin-shell,
.admin-shell *,
.admin-content,
.admin-content *,
.admin-topbar,
.admin-topbar *,
.admin-card,
.admin-card *,
.admin-table,
.admin-table *,
html.lesson-embed,
html.lesson-embed *,
html.is-admin,
html.is-admin *,
body.is-admin,
body.is-admin *,
body.admin-page,
body.admin-page * {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(37, 99, 235, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 85%);
  z-index: 0;
}

.topbar,
.layout,
.page-simple {
  position: relative;
  z-index: 1;
}

/* ── Topbar ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.topbar::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #1d4ed8, #d97706);
}

.topbar-inner {
  position: relative;
  width: 100%;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-start {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.08rem;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  margin: 0 auto;
  flex: 0 0 auto;
}

.topbar-link {
  padding: 0.48rem 0.95rem;
  border-radius: 999px;
  color: #475569;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.topbar-link:hover {
  color: #0f172a;
  background: #ffffff;
}

.topbar-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.topbar-mobile-actions {
  display: none;
}

.topbar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex: 1 1 0;
  min-width: 0;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1.05rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.topbar-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  filter: brightness(1.05);
}

.topbar-admin-link {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.topbar-admin-link:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
}

.topbar-brand:hover {
  opacity: 0.85;
}

.topbar-brand-badge {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  font-size: 1.1rem;
}

.topbar-toggle {
  display: none;
  appearance: none;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}

.topbar-toggle-icon {
  font-size: 1rem;
  line-height: 1;
}

.study-menu-toggle {
  display: none;
  appearance: none;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  padding: 0.48rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 4px 14px var(--accent-glow);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.study-menu-toggle.hidden {
  display: none !important;
}

/* ── Layout ── */

.layout {
  display: flex;
  width: 100%;
  min-height: calc(100vh - var(--topbar-height));
  flex-direction: row;
}

.page-simple {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3.5rem;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 2rem 3rem;
  animation: fadeUp 0.55s ease both;
}

@media (min-width: 1025px) {
  .layout.layout--menus-hidden {
    justify-content: center;
  }

  .layout.layout--menus-hidden .content {
    flex: 0 1 840px;
    max-width: 840px;
    width: 100%;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Hero & Typography ── */

.content-header {
  margin-bottom: 1.75rem;
}

.hero {
  padding: 2rem 2rem 1.85rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.97) 0%, rgba(245, 247, 255, 0.92) 100%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset-inline-start: -3rem;
  top: -3rem;
  width: 11rem;
  height: 11rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.25), transparent 68%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -2rem;
  bottom: -2.5rem;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.2), transparent 70%);
  pointer-events: none;
}

.hero-compact {
  padding: 1.5rem 1.65rem;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.65rem;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(14, 165, 233, 0.1));
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 38rem;
  position: relative;
  z-index: 1;
}

.hero-title,
h1 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.95rem, 5vw, 2.75rem);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 20%, var(--accent) 55%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
  position: relative;
  z-index: 1;
}

.hero-menu-btn {
  display: none;
  margin-top: 1rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 6px 20px var(--accent-glow);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 2;
  max-width: 100%;
  text-align: center;
  line-height: 1.4;
}

@media (min-width: 1025px) {
  .hero-menu-btn,
  .sidebar-open {
    display: none !important;
  }
}

.hero-menu-btn.hidden {
  display: none !important;
}

.hero-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}

/* ── Version banner (home ↔ v2) ── */

.v2-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(79, 70, 229, 0.07);
  border: 1px dashed rgba(79, 70, 229, 0.28);
  font-size: 0.9rem;
  color: var(--muted);
}

.v2-banner strong {
  color: var(--accent);
}

.v2-banner-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.v2-banner-link:hover {
  text-decoration: underline;
}

/* ── Home: Steps & Features ── */

.welcome-panel {
  display: grid;
  gap: 1.25rem;
}

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

.step-card {
  padding: 1.45rem 1.3rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
  position: relative;
  overflow: hidden;
}

.step-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  opacity: 0.7;
}

.step-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(79, 70, 229, 0.22);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.75rem;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.step-card h3,
.feature-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.step-card p,
.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.feature-card {
  padding: 1.45rem 1.3rem;
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96), rgba(238, 242, 255, 0.75));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease;
}

.feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(79, 70, 229, 0.28);
  box-shadow: var(--shadow);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 2.65rem;
  height: 2.65rem;
  margin-bottom: 0.75rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--accent-soft), rgba(14, 165, 233, 0.1));
  font-size: 1.35rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.welcome-panel.hidden {
  display: none;
}

/* ── Info pages ── */

.info-panel {
  padding: 1.65rem 1.7rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.info-highlight {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.15rem 1.2rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), rgba(14, 165, 233, 0.08));
  border: 1px solid var(--border);
}

.info-highlight-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.info-highlight h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.info-highlight p {
  margin: 0;
  color: var(--muted);
}

.section-label {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 800;
}

.check-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.check-list li {
  position: relative;
  padding-inline-start: 1.65rem;
  color: var(--muted);
}

.check-list li::before {
  content: "✓";
  position: absolute;
  inset-inline-start: 0;
  color: var(--accent);
  font-weight: 800;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.contact-card {
  padding: 1.15rem 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--accent-soft), rgba(255, 255, 255, 0.6));
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}

.contact-card:hover {
  transform: translateY(-2px);
}

.contact-icon {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 0.45rem;
}

.contact-card h2 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

.contact-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.contact-card a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.contact-card a:hover {
  text-decoration: underline;
}

.contact-form {
  display: grid;
  gap: 0.7rem;
}

.contact-form label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  justify-self: start;
  margin-top: 0.35rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.45rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px var(--accent-glow);
}

.faq-list details {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.faq-list details:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-list details:first-child {
  padding-top: 0;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "+";
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  display: grid;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.1rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.faq-list details[open] summary::after {
  content: "−";
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
}

.faq-list p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  padding-inline-end: 2rem;
}

.faq-list a {
  color: var(--accent);
  font-weight: 700;
}

/* ── Topic page ── */

.topic-body {
  padding: 0;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topic-lead {
  padding: 1.35rem 1.5rem;
  font-size: 1.05rem;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent-soft), rgba(14, 165, 233, 0.06));
  border-bottom: 1px solid var(--border);
}

.topic-placeholder {
  padding: 2rem 1.5rem;
  text-align: center;
}

.topic-placeholder-icon {
  display: inline-grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 0.85rem;
  border-radius: 1rem;
  background: var(--accent-soft);
  font-size: 1.65rem;
}

.topic-placeholder h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.topic-placeholder p {
  margin: 0 auto;
  max-width: 28rem;
  color: var(--muted);
}

/* ── Sidebars ── */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px) saturate(1.3);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.28s ease, width 0.28s ease, opacity 0.28s ease;
  box-shadow: 4px 0 24px rgba(30, 27, 75, 0.04);
}

.sidebar-main {
  box-shadow: inset 1px 0 0 rgba(30, 27, 75, 0.04);
}

.sidebar-topics {
  background: rgba(248, 250, 255, 0.95);
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border: none;
  opacity: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.15rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.06), transparent);
}

.sidebar-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
}

.sidebar-toggle,
.sidebar-open,
.nav-btn {
  appearance: none;
  border: none;
  font: inherit;
  cursor: pointer;
  background: transparent;
}

.sidebar-toggle {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  transition: background 0.2s ease;
}

.sidebar-toggle:hover {
  background: var(--accent-soft);
}

.nav-tree,
.topics-nav {
  padding: 0.85rem 0.75rem;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 0.45rem;
}

.nav-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.78rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  background: rgba(79, 70, 229, 0.04);
  font: inherit;
  font-weight: 800;
  text-align: start;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-group-btn:hover {
  background: var(--accent-soft);
  border-color: var(--border);
}

.nav-group.open .nav-group-btn {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.08));
  border-color: var(--border);
}

.nav-group-btn .chevron {
  transition: transform 0.25s ease;
  color: var(--muted);
  font-size: 0.75rem;
}

.nav-group.open .nav-group-btn .chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.nav-sublist {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0 0.25rem 0.25rem;
  display: none;
}

.nav-group.open .nav-sublist {
  display: block;
}

.nav-sublist .nav-btn {
  width: 100%;
  padding: 0.68rem 0.9rem 0.68rem 1.15rem;
  border-radius: 0.7rem;
  text-align: start;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-sublist .nav-btn:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.nav-sublist .nav-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.topics-nav {
  display: grid;
  gap: 0.35rem;
}

.topics-nav .lesson-group {
  margin-bottom: 0.15rem;
}

.topics-nav .lesson-group-btn {
  padding: 0.68rem 0.85rem;
  font-size: 0.92rem;
}

.topics-nav .lesson-group-list {
  display: none;
  gap: 0.3rem;
  margin: 0.3rem 0 0.15rem;
  padding: 0 0.15rem 0.1rem;
}

.topics-nav .lesson-group.open .lesson-group-list {
  display: grid;
}

.topics-nav .lesson-group-list .topic-link {
  padding: 0.68rem 0.85rem;
  font-size: 0.9rem;
}

.lesson-group-loose {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.topic-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.78rem 0.95rem;
  border-radius: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.topic-link-title {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.lesson-access-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.lesson-access-badge--free {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.lesson-access-badge--locked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.4rem;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.lesson-access-lock-icon {
  display: block;
}

.topic-link.active .lesson-access-badge--free {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.topic-link.active .lesson-access-badge--locked {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.topic-link:hover {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--border);
  transform: translateX(-3px);
  box-shadow: var(--shadow-sm);
}

.topic-link.active {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 14px var(--accent-glow);
  border-color: transparent;
}

.sidebar-open {
  position: fixed;
  top: calc(var(--topbar-height) + 0.85rem);
  inset-inline-start: 1rem;
  z-index: 20;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--accent-glow);
  transition: transform 0.2s ease;
  touch-action: manipulation;
}

.sidebar-open:hover {
  transform: scale(1.03);
}

.sidebar-open.hidden {
  display: none;
}

/* ── Responsive ── */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  .topbar-link {
    padding: 0.42rem 0.65rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 860px) {
  :root {
    --topbar-height: 60px;
  }

  .topbar-toggle {
    display: inline-flex;
  }

  .topbar-action-btn {
    display: none;
  }

  .topbar-end {
    flex-wrap: nowrap;
    min-width: 0;
    overflow: visible;
    flex-shrink: 0;
  }

  .topbar-admin-link {
    display: none;
  }

  .study-menu-toggle {
    padding: 0.42rem 0.75rem;
    font-size: 0.82rem;
  }

  .topbar-inner {
    padding: 0 0.85rem;
    gap: 0.5rem;
  }

  .topbar-brand {
    font-size: 0.98rem;
    min-width: 0;
  }

  .topbar-nav {
    position: fixed;
    inset-inline: 0.75rem;
    top: calc(var(--topbar-height) + 0.35rem);
    z-index: 45;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 0.65rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    margin: 0;
  }

  .topbar-nav.open {
    display: flex;
  }

  .topbar-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
  }

  .topbar-link {
    display: block;
    width: 100%;
    padding: 0.65rem 0.95rem;
    font-size: 0.95rem;
    text-align: inherit;
    border-radius: 8px;
  }

  .content {
    padding: 1.15rem 0.85rem 5.5rem;
  }

  .page-simple {
    padding: 1.15rem 0.85rem 2.5rem;
  }

  .hero {
    padding: 1.2rem 1rem;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, 0.94) 0%, rgba(245, 247, 255, 0.9) 100%);
  }

  .hero-compact {
    padding: 1rem;
  }

  .hero-title,
  h1 {
    font-size: clamp(1.45rem, 6vw, 2rem);
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .steps-grid,
  .feature-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .info-panel {
    padding: 1.15rem 1rem;
  }

  .info-highlight {
    flex-direction: column;
    gap: 0.65rem;
  }

  .topic-lead {
    padding: 1rem;
    font-size: 0.98rem;
  }

  .topic-placeholder {
    padding: 1.5rem 1rem;
  }

  .faq-list p {
    padding-inline-end: 0;
  }
}

@media (max-width: 380px) {
  .topbar-brand-text {
    display: none;
  }

  .topbar-toggle span:not(.topbar-toggle-icon) {
    display: none;
  }
}

@media (max-width: 1024px) {
  :root {
    --bg: #f8fafc;
    --surface-solid: #ffffff;
    --topbar-height: 60px;
  }

  body {
    animation: none;
    background-color: var(--bg);
    background-image:
      radial-gradient(ellipse 80% 50% at 100% 0%, rgba(37, 99, 235, 0.05), transparent 50%),
      radial-gradient(ellipse 70% 45% at 0% 100%, rgba(217, 119, 6, 0.04), transparent 45%);
  }

  body::before {
    display: none;
  }

  .topbar {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px) saturate(1.2);
  }

  .topbar-toggle {
    display: inline-flex;
  }

  .study-menu-toggle:not(.hidden) {
    display: inline-flex;
  }

  .hero-menu-btn:not(.hidden) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    white-space: normal;
  }

  .hero-title,
  h1 {
    -webkit-text-fill-color: var(--text);
    color: var(--text);
    background: none;
  }

  .hero {
    padding: 1.2rem 1rem;
    background: var(--surface-solid);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
  }

  .hero-stat {
    background: rgba(244, 246, 250, 0.95);
  }

  .step-card,
  .feature-card {
    background: var(--surface-solid);
    padding: 1.15rem 1rem;
  }

  .content {
    padding: 1rem 0.85rem 5.5rem;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* لا نحبس القائمة داخل طبقة z-index منخفضة */
  .layout {
    display: block;
    position: static;
    z-index: auto;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    z-index: 90;
    background: rgba(30, 27, 75, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }

  .sidebar-backdrop.visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: auto !important;
    right: 0 !important;
    z-index: 100;
    width: min(var(--sidebar-width), 86vw) !important;
    max-width: 300px;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: -webkit-transform 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
    will-change: transform;
  }

  .sidebar-topics:not(.collapsed) {
    z-index: 101;
  }

  .sidebar.collapsed {
    -webkit-transform: translate3d(100%, 0, 0);
    transform: translate3d(100%, 0, 0);
    width: min(var(--sidebar-width), 86vw) !important;
    max-width: 300px;
    overflow: hidden;
    pointer-events: none !important;
    visibility: hidden;
    z-index: -1;
  }

  .sidebar-open {
    top: auto;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(0.85rem + env(safe-area-inset-inline-start, 0px));
    left: auto;
    padding: 0.72rem 1.05rem;
    font-size: 0.88rem;
    z-index: 110;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-open-main {
    right: calc(0.85rem + env(safe-area-inset-inline-start, 0px));
    left: auto;
  }

  .sidebar-open-topics {
    right: auto;
    left: calc(0.85rem + env(safe-area-inset-inline-end, 0px));
  }

  .sidebar-open.hidden {
    display: none !important;
  }

  .sidebar-open:not(.hidden) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-tree,
  .topics-nav {
    max-height: calc(100dvh - var(--topbar-height) - 4.5rem);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    position: relative;
    z-index: 1;
    pointer-events: auto;
  }

  .sidebar-head {
    position: relative;
    z-index: 1;
    pointer-events: auto;
  }

  .nav-group-btn,
  .nav-btn {
    position: relative;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

@media (hover: none) {
  .step-card:hover,
  .feature-card:hover,
  .contact-card:hover,
  .comment-item:hover,
  .lesson-block:hover,
  .topic-link:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ── حماية المحتوى من النسخ والتنزيل والطباعة ── */
input, textarea {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

img, svg, canvas, video, audio, iframe, embed, object {
  -webkit-user-drag: none !important;
  -khtml-user-drag: none !important;
  -moz-user-drag: none !important;
  -o-user-drag: none !important;
  user-drag: none !important;
}

@media print {
  html, body {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }
}

