:root {
  --bg: #f0f4f8;
  --bg-pattern: #e2e8f0;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.12);
  --primary-glow: rgba(13, 148, 136, 0.25);
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --header-bg: linear-gradient(135deg, #0f766e 0%, #115e59 48%, #134e4a 100%);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 40px -10px rgba(15, 23, 42, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cairo", system-ui, sans-serif;
  --sidebar-w: 300px;
}

html {
  direction: rtl;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100%;
}

code.code-inline,
.code-inline {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.lms {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
  -webkit-tap-highlight-color: rgba(13, 148, 136, 0.15);
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(13, 148, 136, 0.08), transparent 50%),
    radial-gradient(ellipse 80% 50% at 0% 100%, rgba(124, 58, 237, 0.06), transparent 45%);
  line-height: 1.6;
  overflow-x: hidden;
  padding-inline: max(0px, env(safe-area-inset-left, 0px)) max(0px, env(safe-area-inset-right, 0px));
}

code {
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  border: 1px solid var(--border);
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ——— Header ——— */
.header {
  background: var(--header-bg);
  color: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.2);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-logo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: block;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0;
  text-align: start;
  color: #fff;
  line-height: 1.25;
}

.brand-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: rgba(248, 250, 252, 0.85);
  text-align: start;
  font-weight: 500;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #ecfdf5;
}

.header-badge-icon {
  color: #5eead4;
  font-size: 0.65rem;
}

/* ——— Hero ——— */
.hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 0.65rem;
}

.hero-inner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem 2rem;
}

.hero-art {
  flex: 0 1 auto;
  width: clamp(112px, 24vw, 168px);
  max-width: 168px;
  min-width: 0;
}

.hero-illustration {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.progress-strip {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 1.25rem;
}

.progress-strip-inner {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}

.hero-copy {
  flex: 1 1 260px;
  min-width: 0;
  text-align: start;
}

.hero-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.hero-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 800;
  color: var(--text);
  text-align: start;
  line-height: 1.3;
}

.hero-title--course {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: start;
  gap: 0.12em 0.2em;
  text-align: start;
  margin-bottom: 0.65rem;
  font-size: clamp(1.05rem, 2.5vw, 1.55rem);
  font-weight: 800;
  line-height: 1.35;
  color: var(--text);
}

.hero-title--course .hero-title-line {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}

.hero-title--course .hero-title-api {
  font-size: 1.2em;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  color: var(--text);
}

.hero-desc {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  text-align: start;
  max-width: 52ch;
  line-height: 1.65;
}

.hero-progress {
  background: linear-gradient(145deg, var(--surface-2), #fff);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.25rem 0;
  border: none;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}

.progress-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.progress-fraction {
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 11.11%;
  background: linear-gradient(90deg, var(--primary), #14b8a6);
  border-radius: 999px;
  transition: width 0.35s ease;
  box-shadow: 0 0 12px var(--primary-glow);
}

/* ——— Layout ——— */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  align-items: start;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 92px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-head {
  padding: 1.1rem 1.15rem;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  text-align: start;
}

.sidebar-meta {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 600;
  text-align: start;
}

.lesson-list {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(70vh, 640px);
  overflow-y: auto;
}

.lesson-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  text-align: start;
  padding: 0.75rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  color: inherit;
}

.lesson-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.lesson-item.active {
  background: var(--primary-soft);
  border-color: rgba(13, 148, 136, 0.35);
  box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.15);
}

.lesson-item.active .lesson-num {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}

.lesson-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-size: 0.8125rem;
  font-weight: 800;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.lesson-item-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lesson-item-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lesson-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

/* ——— Main lesson panel ——— */
.content {
  min-width: 0;
}

.lesson-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 1.35rem 1.5rem 1.75rem;
  overflow-x: hidden;
  min-width: 0;
}

.mobile-lesson-nav {
  display: none;
}

.mobile-lesson-label {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.lesson-select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.lesson-nav-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.lesson-nav-btn {
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}

.lesson-nav-btn--next {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
}

.lesson-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.breadcrumb-root {
  color: var(--text-secondary);
}

.breadcrumb-sep {
  color: var(--border);
  user-select: none;
}

.breadcrumb-current {
  color: var(--primary-dark);
  font-weight: 700;
}

.lesson-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

.course-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 800;
  margin: 0 0 0.4rem;
  text-align: start;
  color: var(--text);
  line-height: 1.3;
}

.course-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  max-width: 100%;
  text-align: start;
  line-height: 1.65;
  white-space: pre-line;
  min-width: 0;
}

.course-desc--rich {
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.course-desc--rich h3,
.course-desc--rich h4 {
  overflow-wrap: anywhere;
}

.course-desc--rich pre {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0.35rem 0 0.85rem;
  padding: 0.7rem 0.75rem;
  overflow-x: auto;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.course-desc--rich pre code {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre-wrap !important;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-size: 0.8rem;
  line-height: 1.55;
}

.course-desc--rich p {
  margin: 0 0 0.85rem;
}

.course-desc--rich p:last-child {
  margin-bottom: 0;
}

.course-desc--rich .task-link-wrap {
  margin: 0.5rem 0 1rem;
}

.course-desc--rich .task-api-link {
  word-break: break-all;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.course-desc--rich .task-field-list {
  margin: 0.35rem 0 0;
  padding-inline-start: 1.25rem;
  line-height: 1.7;
}

.course-desc--rich .task-field-list code {
  font-size: 0.88em;
}

.course-desc--rich .project-highlight-card {
  margin-top: 1.1rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(13, 148, 136, 0.4);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(124, 58, 237, 0.08));
  box-shadow: 0 8px 24px -16px rgba(13, 148, 136, 0.6);
}

.course-desc--rich .project-highlight-card h4 {
  margin: 0 0 0.45rem;
  color: var(--primary-dark);
}

.course-desc--rich .project-highlight-card p:last-child {
  margin-bottom: 0;
}

.course-desc--rich .api-submenu-list {
  display: grid;
  gap: 0.4rem;
}

.course-desc--rich .api-problem-card {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.course-desc--rich .api-problem-card h4 {
  margin: 0 0 0.55rem;
  font-size: 1.12rem;
  font-weight: 800;
}

.course-desc--rich .api-problem-card p {
  margin: 0 0 0.6rem;
}

.course-desc--rich .api-problem-card pre {
  margin: 0.35rem 0 0;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  overflow-x: auto;
}

.course-desc--rich .api-problem-1 {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(37, 99, 235, 0.06));
  border-color: rgba(59, 130, 246, 0.35);
}

.course-desc--rich .api-problem-2 {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(225, 29, 72, 0.05));
  border-color: rgba(244, 63, 94, 0.35);
}

.course-desc--rich .api-problem-3 {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(217, 119, 6, 0.06));
  border-color: rgba(245, 158, 11, 0.35);
}

.course-desc--rich .api-problem-4 {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.14), rgba(194, 65, 12, 0.06));
  border-color: rgba(249, 115, 22, 0.35);
}

.course-desc--rich .api-problem-5 {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(5, 150, 105, 0.06));
  border-color: rgba(16, 185, 129, 0.35);
}

.course-desc--rich .api-mindmap {
  margin-top: 0.85rem;
}

.course-desc--rich .api-mindmap-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  margin-bottom: 0.85rem;
  border-radius: 16px;
  background: #0f766e;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.course-desc--rich .api-mindmap-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}

.course-desc--rich .api-mind-node {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.course-desc--rich .api-mind-q {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
}

.course-desc--rich .api-mind-code {
  align-self: flex-start;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

.course-desc--rich .api-mind-timeout {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.08);
}
.course-desc--rich .api-mind-timeout .api-mind-code {
  background: #2563eb;
  color: #fff;
}

.course-desc--rich .api-mind-401 {
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.08);
}
.course-desc--rich .api-mind-401 .api-mind-code {
  background: #e11d48;
  color: #fff;
}

.course-desc--rich .api-mind-403 {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.08);
}
.course-desc--rich .api-mind-403 .api-mind-code {
  background: #7c3aed;
  color: #fff;
}

.course-desc--rich .api-mind-400 {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
}
.course-desc--rich .api-mind-400 .api-mind-code {
  background: #d97706;
  color: #fff;
}

.course-desc--rich .api-mind-404 {
  border-color: rgba(14, 165, 233, 0.4);
  background: rgba(14, 165, 233, 0.08);
}
.course-desc--rich .api-mind-404 .api-mind-code {
  background: #0284c7;
  color: #fff;
}

.course-desc--rich .api-mind-429 {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.1);
}
.course-desc--rich .api-mind-429 .api-mind-code {
  background: #ea580c;
  color: #fff;
}

.course-desc--rich .api-mind-5xx {
  border-color: rgba(71, 85, 105, 0.4);
  background: rgba(71, 85, 105, 0.08);
}
.course-desc--rich .api-mind-5xx .api-mind-code {
  background: #334155;
  color: #fff;
}

.course-desc--rich .api-refs-card {
  margin-top: 1.15rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(13, 148, 136, 0.35);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(15, 23, 42, 0.02));
}

.course-desc--rich .api-refs-card h4 {
  margin: 0 0 0.4rem;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.course-desc--rich .api-refs-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.course-desc--rich .api-refs-list li {
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
}

.course-desc--rich .api-refs-list a {
  display: block;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.course-desc--rich .api-refs-list span {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.empty-state .api-ref-empty {
  margin: 0.65rem 0 0;
  padding-inline-start: 1.2rem;
  line-height: 1.8;
}

.empty-state .api-ref-empty a {
  color: #5eead4;
  font-weight: 700;
}

.lesson-item--task {
  border-color: rgba(124, 58, 237, 0.25);
}

.lesson-item--task.active {
  background: var(--accent-soft);
  border-color: rgba(124, 58, 237, 0.45);
}

.lesson-item--task.active .lesson-num {
  background: var(--accent);
  color: #fff;
  border-color: #5b21b6;
}

.content-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 1.15rem;
}

.content-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.content-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.content-tab.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.content-tab-icon {
  font-size: 0.75rem;
  opacity: 0.85;
}

.player-card,
.resource-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.player-card {
  border: 1px solid var(--border);
  background: #0a0a0b;
}

.resource-card {
  padding: 1.35rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.resource-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  text-align: start;
}

.video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  background: #000;
  border-radius: 0;
  overflow: hidden;
}

.video-wrap iframe,
.video-wrap video.video-native {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-wrap video.video-native {
  object-fit: contain;
  background: #000;
}

.lesson-meta-row {
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: rgba(248, 250, 252, 0.75);
}

.meta-pill-label {
  font-weight: 600;
  color: rgba(248, 250, 252, 0.55);
}

.view-count {
  font-weight: 700;
  color: #ecfdf5;
}

.empty-state {
  margin: 0;
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(248, 250, 252, 0.85);
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: start;
}

.empty-state code {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.pdf-intro {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  text-align: start;
}

.btn-pdf {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.35rem;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-pdf-icon {
  font-size: 1rem;
}

.hint {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: start;
}

.hidden {
  display: none !important;
}

.subpanel {
  display: none;
}

.subpanel.active {
  display: block;
}

/* ——— Footer ——— */
.footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem max(2.5rem, calc(1rem + env(safe-area-inset-bottom, 0px)));
}

.footer-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  text-align: start;
}

.footer-title {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.footer-card p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ——— Responsive ——— */
@media (max-width: 960px) {
  .hero-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-art {
    width: 100%;
    max-width: 150px;
    margin-inline: auto;
    order: -1;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-lesson-nav {
    display: block;
    margin: 0 0 1.1rem;
    padding: 0.9rem;
    background: var(--primary-soft);
    border: 1px solid rgba(13, 148, 136, 0.3);
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 600px) {
  .header-inner {
    padding: 0.85rem 1rem;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .header-badge {
    width: 100%;
    justify-content: center;
  }

  .hero {
    padding: 1rem 1rem 0.5rem;
  }

  .progress-strip {
    padding: 0 1rem 1rem;
  }

  .hero-inner {
    padding: 1.15rem;
  }

  .layout {
    padding: 1rem 1rem 1.5rem;
  }

  .lesson-panel {
    padding: 1rem 1.1rem 1.35rem;
  }

  .content-tabs {
    flex-direction: column;
    width: 100%;
  }

  .content-tab {
    justify-content: center;
  }

  .hero-desc {
    max-width: none;
  }

  .brand-title,
  .brand-sub,
  .course-title,
  .lesson-item-title,
  .footer-card p {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .course-desc--rich .api-mindmap-branches {
    grid-template-columns: 1fr;
  }

  .course-desc--rich .api-problem-card,
  .course-desc--rich .project-highlight-card,
  .course-desc--rich .api-refs-card {
    padding: 0.85rem 0.8rem;
  }

  .player-card,
  .meta-pill,
  .empty-state {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .empty-state .api-ref-empty a {
    word-break: break-all;
  }
}

/* شاشات ضيقة جداً */
@media (max-width: 400px) {
  .lesson-item {
    min-width: min(100%, 200px);
    max-width: 100%;
  }

  .hero-inner {
    padding: 1rem;
  }

  .lesson-panel {
    padding: 0.85rem 0.9rem 1.15rem;
  }
}

/* أجهزة لمس: أزرار أسهل للضغط */
@media (hover: none) and (pointer: coarse) {
  .lesson-item {
    min-height: 48px;
    padding: 0.85rem 1rem;
  }

  .content-tab {
    min-height: 48px;
    padding: 0.65rem 1.1rem;
  }

  .btn-pdf {
    min-height: 48px;
    align-items: center;
  }
}
