/* tn-lib-cache:learn23 */
/* Learning surfaces — programs, courses, theory reader, quiz focus.
   Loaded after app.css. Does not change Authz / Demo / scoring. */

.tk-course-hero {
  background:
    radial-gradient(80% 120% at 0% 0%, rgba(var(--tn-accent-rgb), 0.28), transparent 55%),
    linear-gradient(135deg, var(--tn-night, #0b1220) 0%, var(--tn-night-soft, #1a2436) 100%);
  box-shadow: var(--tn-shadow-sm, 0 4px 14px rgba(11, 18, 32, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tk-course-hero__stats div {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.tk-course-hero .tn-btn--on-dark,
.tk-course-hero .btn-secondary {
  border-color: rgba(255, 255, 255, 0.3);
}

/* Hero CTA on dark — solid sky chip, white label, gold plus */
.tk-course-hero .tk-course-actions .tn-btn--on-dark {
  background: var(--tn-accent, #007AFF) !important;
  border: 1px solid rgba(255, 255, 255, 0.45) !important;
  color: #fff !important;
  font-weight: 700;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 8px 20px rgba(0, 122, 255, 0.35);
}

.tk-course-hero .tk-course-actions .tn-btn--on-dark:hover:not(:disabled) {
  background: var(--tn-accent-hover, #0066D6) !important;
  color: #fff !important;
}

.tk-course-hero .tk-course-actions .tn-btn--on-dark i {
  color: #f0bf77 !important;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

/* Program / course cards — luxury surface */
.tk-program-card,
.tk-course-card {
  position: relative;
  border-radius: 1.15rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 10px 28px rgba(11, 18, 32, 0.06);
  padding: 1.15rem 1.15rem 1.05rem;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.tk-program-card:hover,
.tk-course-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 18px 36px rgba(11, 18, 32, 0.1),
    0 0 0 1px rgba(0, 122, 255, 0.18);
}

.tk-program-card .tk-course-card__icon,
.tk-course-card .tk-course-card__icon {
  margin: 0 auto 1.05rem;
}

.tk-program-card .tk-course-card__meta,
.tk-course-card .tk-course-card__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--tn-accent-soft, #E8F1FF);
  color: #8a6a2f;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tk-program-card h3,
.tk-course-card h3 {
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--tn-ink, #0f172a);
  margin: 0 0 0.35rem;
}

.tk-program-card > p,
.tk-course-card > p:not(.tk-course-card__meta) {
  color: var(--tn-ink-muted, #64748b);
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.tk-program-card .tn-btn--block {
  margin-top: auto;
}

.tk-program-card__actions .tn-btn,
.tk-program-card__actions .btn {
  flex: 1 1 auto;
}

/* Theory reader */
.tn-reader-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 992px) {
  .tn-reader-layout {
    grid-template-columns: minmax(14rem, 17.5rem) minmax(0, 1fr);
    align-items: start;
  }
}

.tn-reader-toc {
  border: 1px solid var(--tn-line, #e2e8f0);
  border-radius: var(--tn-radius-lg, 0.875rem);
  background: var(--tn-surface, #fff);
  padding: 1rem 1.1rem;
}

/* Sticky chapter rail only on desktop — on phones it ate the viewport while scrolling */
@media (min-width: 992px) {
  .tn-reader-toc {
    position: sticky;
    top: 1rem;
    max-height: calc(100dvh - 2rem);
    overflow: auto;
  }
}

@media (max-width: 991.98px) {
  .tn-reader-toc {
    position: static;
    max-height: min(42vh, 18rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tn-reader__mast {
    position: sticky;
    top: 0;
    z-index: 30;
    margin-bottom: 0.85rem;
    padding: 0.65rem 0 0.75rem;
    background: rgba(248, 250, 252, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: padding 160ms ease, box-shadow 160ms ease;
  }

  /* Sit under LMS sticky topbar when present */
  body.tk-app .tn-reader__mast {
    top: 3.6rem;
  }

  .tn-reader__mast.is-compact {
    padding: 0.35rem 0 0.45rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  }

  .tn-reader__mast.is-compact .tn-type-label,
  .tn-reader__mast.is-compact .tn-reader__lede,
  .tn-reader__mast.is-compact .tn-btn {
    display: none !important;
  }

  .tn-reader__mast.is-compact .tn-type-page {
    font-size: 1.05rem;
    line-height: 1.25;
    margin: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tn-reader__mast.is-compact > div {
    min-width: 0;
    flex: 1 1 auto;
  }
}

.tn-reader-page {
  border: 1px solid var(--tn-line, #e2e8f0);
  border-radius: var(--tn-radius-lg, 0.875rem);
  background: var(--tn-surface, #fff);
  padding: 1.25rem 1.35rem 1.5rem;
}

.tn-reader-page .tk-prose {
  max-width: 42rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--tn-ink, #0f172a);
}

.tn-reader-practice {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: var(--tn-radius-lg, 0.875rem);
  border: 1px solid rgba(var(--tn-accent-rgb, 42, 143, 110), 0.28);
  background: var(--tn-accent-soft, #e8f5f0);
}

.tn-reader-practice__copy .tn-type-label {
  margin: 0 0 0.2rem;
}

.tn-reader-practice__copy h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.tn-reader-practice__copy p {
  margin: 0;
  color: var(--tn-ink-muted, #5a6b7d);
  font-size: 0.92rem;
  line-height: 1.45;
}

.tn-reader-practice__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tn-reader-practice__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.tn-reader-practice__list a {
  color: var(--tn-ink, #0f172a);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  font-size: 0.92rem;
}

.tn-reader-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tn-line, #e2e8f0);
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .tn-reader-layout {
    grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
  }
}

/* Student / demo dashboard: next action first */
.tn-dash-next {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: var(--tn-radius-lg, 0.875rem);
  border: 1px solid rgba(var(--tn-accent-rgb), 0.28);
  background: var(--tn-accent-soft, #E8F1FF);
}

.tn-dash-next__copy h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--tn-ink, #0f172a);
}

.tn-dash-next__copy p {
  margin: 0;
  color: var(--tn-ink-muted, #475569);
  font-size: 0.95rem;
}

/* ——— Quiz taking (practice) — app shell, readable spacing, dvh + safe-area ——— */
html:has(body.tn-quiz-focus),
body.tn-quiz-focus {
  height: 100%;
  overflow: hidden;
}

body.tn-quiz-focus {
  --tn-quiz-scale: 0.92;
  --tn-quiz-pad-x: 0.95rem;
  --tn-quiz-pad-b: max(1rem, env(safe-area-inset-bottom, 0px));
  --tn-quiz-gap: 0.55rem;
  --tn-quiz-img-max: min(28vh, 12.5rem);
  --tn-quiz-img-max: min(28dvh, 12.5rem);
  background: #f2f4f8;
  font-family: var(--tk-font, "Poppins", "Noto Sans Arabic", sans-serif);
  touch-action: manipulation;
}

body.tn-quiz-focus #side-nav,
body.tn-quiz-focus .tk-crumb,
body.tn-quiz-focus .title-1,
body.tn-quiz-focus .exam-lang-notice,
body.tn-quiz-focus #top-navbar,
body.tn-quiz-focus .tn-topbar {
  display: none !important;
}

body.tn-quiz-focus #main,
body.tn-quiz-focus #main-content.container-fluid,
body.tn-quiz-focus #main-content {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  background: #f2f4f8;
  overflow: hidden;
}

.tn-quiz-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  height: 100%;
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
  padding: 0 0 var(--tn-quiz-pad-b);
  box-sizing: border-box;
  overflow: hidden;
}

.tn-quiz-appbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  padding: 0.55rem var(--tn-quiz-pad-x);
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  background: #fff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  z-index: 20;
}

.tn-quiz-appbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  min-width: 2.15rem;
  min-height: 2.15rem;
  border-radius: 999px;
  color: var(--tn-ink, #0f172a);
  text-decoration: none;
  background: #f1f5f9;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.tn-quiz-appbar__back:hover {
  background: #e2e8f0;
}

html[dir="rtl"] .tn-quiz-appbar__back i {
  transform: scaleX(-1);
}

.tn-quiz-appbar__meta {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
}

.tn-quiz-appbar__title {
  margin: 0;
  font-size: calc(0.92rem * var(--tn-quiz-scale) / 0.85);
  font-weight: 650;
  color: var(--tn-ink, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.tn-quiz-appbar__count {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--tn-accent, #007AFF);
  font-variant-numeric: tabular-nums;
  background: var(--tn-accent-soft, #E8F1FF);
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}

.tn-quiz-appbar__exit {
  flex-shrink: 0;
  margin-inline-start: 0.25rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--tn-ink, #0f172a);
  text-decoration: none;
  background: #f1f5f9;
}

.tn-quiz-appbar__exit:hover {
  background: #e2e8f0;
}

.tn-quiz-resume {
  margin: 1.5rem auto;
  max-width: 28rem;
  padding: 1.35rem 1.25rem 1.5rem;
  border-radius: var(--tn-radius-lg, 0.875rem);
  border: 1px solid var(--tn-line, #e2e8f0);
  background: #fff;
  text-align: center;
}

.tn-quiz-resume__lede {
  margin: 0.65rem 0 1.15rem;
  color: var(--tn-ink-muted, #5a6b7d);
  line-height: 1.5;
}

.tn-quiz-resume__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.tn-quiz-resume__leave {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.tn-quiz-resume__leave a {
  color: var(--tn-ink-muted, #5a6b7d);
}

.tn-quiz-progress {
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: #fff;
}

.tn-quiz-progress__label,
.tn-quiz-progress__count {
  display: none;
}

.tn-quiz-progress__track {
  display: block;
  height: 3px;
  width: 100%;
  background: #e8eef5;
}

.tn-quiz-progress__fill {
  display: block;
  height: 100%;
  width: var(--tn-quiz-pct, 0%);
  max-width: 100%;
  background: linear-gradient(90deg, var(--tk-brand-gold, #f0bf77), var(--tn-accent, #007AFF));
  transition: width 0.25s ease;
}

.tn-quiz-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem var(--tn-quiz-pad-x) 0;
  overflow: hidden;
}

.tn-quiz-card {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 0.95rem;
  background: #fff;
  padding: 1rem 1rem 0.85rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.tn-quiz-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--tk-brand-gold, #f0bf77),
    var(--tn-accent, #007AFF)
  );
}

.tn-quiz-stem,
.tn-quiz-card .lead {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--tn-ink, #0f172a);
  margin: 0 0 0.85rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.tn-quiz-figure {
  margin: 0 auto 0.85rem;
  max-width: min(100%, 22rem);
  text-align: center;
  flex-shrink: 0;
}

.tn-quiz-figure img,
.tn-quiz-figure .tk-q-img,
.tn-quiz-figure .q-img {
  display: block;
  margin-inline: auto;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: var(--tn-quiz-img-max);
  object-fit: contain;
  border-radius: 0.5rem;
  border: 1px solid var(--tn-line, #e2e8f0);
  background: #fff;
}

.tn-quiz-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tn-quiz-answers {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0.25rem;
  display: flex;
  flex-direction: column;
  gap: var(--tn-quiz-gap, 0.55rem);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tn-quiz-option {
  margin: 0;
  padding: 0;
  border: 1px solid var(--tn-line, #e2e8f0);
  border-radius: 0.65rem;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
  min-height: 3rem;
}

.tn-quiz-option:hover {
  border-color: rgba(var(--tn-accent-rgb, 0, 122, 255), 0.5);
  background: var(--tn-accent-soft, #E8F1FF);
}

.tn-quiz-option:focus-within {
  border-color: var(--tn-accent, #007AFF);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.28);
}

.tn-quiz-option:has(input:checked),
.tn-quiz-option.is-selected {
  border-color: var(--tn-accent, #007AFF);
  background: var(--tn-accent-soft, #E8F1FF);
  box-shadow: 0 0 0 1px var(--tn-accent, #007AFF);
}

.tn-quiz-card--revealed .tn-quiz-answers--locked {
  pointer-events: none;
}

/* After answer: scroll the whole reveal (options + explanation), keep Next sticky.
   Previously explain was max-height 14dvh and card overflow:hidden clipped details. */
.tn-quiz-card--revealed {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tn-quiz-card--revealed .tn-quiz-answers--locked {
  flex: 0 0 auto;
  overflow: visible;
  min-height: 0;
}

.tn-quiz-card--revealed .tn-quiz-explain-box {
  flex: 0 0 auto;
  min-height: 0;
}

.tn-quiz-card--revealed .tn-quiz-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  padding-bottom: 0.15rem;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    #fff 28%,
    #fff 100%
  );
}

.tn-quiz-option.is-correct {
  border-color: rgba(22, 163, 74, 0.55);
  background: #ecfdf3;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.35);
}

.tn-quiz-option.is-wrong {
  border-color: rgba(220, 38, 38, 0.5);
  background: #fef2f2;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.28);
}

.tn-quiz-option.is-correct .tn-quiz-option__text,
.tn-quiz-option.is-wrong .tn-quiz-option__text {
  font-weight: 600;
}

.tn-quiz-option__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  width: 100%;
  padding: 0.8rem 0.9rem;
}

.tn-quiz-option__text {
  display: block;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.45;
}

.tn-quiz-option__tag {
  flex-shrink: 0;
  margin-top: 0.05rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--tn-ink-muted, #64748b);
  background: rgba(15, 23, 42, 0.06);
  white-space: nowrap;
}

.tn-quiz-option.is-correct .tn-quiz-option__tag {
  color: #15803d;
}

.tn-quiz-option.is-wrong .tn-quiz-option__tag {
  color: #b91c1c;
}

.tn-quiz-option label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0;
  padding: 0.8rem 0.9rem;
  min-height: 3rem;
  width: 100%;
  cursor: pointer;
  color: var(--tn-ink, #0f172a);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
  box-sizing: border-box;
}

.tn-quiz-option input[type="radio"],
.tn-quiz-option input[type="checkbox"],
.tn-quiz-radio {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--tn-accent, #007AFF);
}

.tn-quiz-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.75rem;
}

.tn-quiz-submit {
  width: 100%;
  min-height: 2.9rem;
  font-size: 0.95rem;
  border-radius: 0.75rem;
  touch-action: manipulation;
}

.tn-quiz-feedback--compact {
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.tn-quiz-feedback--compact > i {
  margin-top: 0;
  font-size: 0.95rem;
}

.tn-quiz-reveal {
  animation: tn-quiz-reveal-in 0.24s ease-out;
}

@keyframes tn-quiz-reveal-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tn-quiz-explain-box {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.tn-quiz-study-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tn-accent, #007AFF);
  text-decoration: none;
}

.tn-quiz-study-link:hover {
  text-decoration: underline;
}

.tn-quiz-focus .tk-quiz-explain {
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 0.55rem;
  /* Full text visible — parent card scrolls when needed */
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tn-quiz-advance {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
}

.tn-quiz-advance__hint {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--tn-ink-muted, #64748b);
}

@media (prefers-reduced-motion: reduce) {
  .tn-quiz-reveal {
    animation: none;
  }
}

/* Tablet / desktop: same app chrome, a bit more air */
@media (min-width: 768px) {
  body.tn-quiz-focus {
    --tn-quiz-pad-x: 1.25rem;
    --tn-quiz-gap: 0.65rem;
    --tn-quiz-img-max: min(32vh, 14rem);
    --tn-quiz-img-max: min(32dvh, 14rem);
  }

  .tn-quiz-shell {
    max-width: 38rem;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.04);
    background: #f2f4f8;
  }

  .tn-quiz-appbar__title {
    font-size: 1rem;
  }

  .tn-quiz-card {
    padding: 1.15rem 1.2rem 1rem;
  }

  .tn-quiz-stem,
  .tn-quiz-card .lead {
    font-size: 1.08rem;
    margin-bottom: 1rem;
  }

  .tn-quiz-option label,
  .tn-quiz-option__text {
    font-size: 1rem;
  }

  .tn-quiz-option label,
  .tn-quiz-option__row {
    padding: 0.9rem 1rem;
  }

  .tn-quiz-submit {
    min-height: 3rem;
  }
}

@media (min-width: 1100px) {
  body.tn-quiz-focus {
    --tn-quiz-img-max: min(30vh, 15rem);
    --tn-quiz-img-max: min(30dvh, 15rem);
  }

  .tn-quiz-shell {
    max-width: 38rem;
  }
}

/* Shared list/grid helpers (quiz index etc.) */
.tn-quiz-previous {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tn-line, #e2e8f0);
}

.tn-quiz-previous .muted {
  color: var(--tn-ink-muted, #64748b);
}

.tn-quiz-review {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
  font-size: 0.95rem;
}

.tn-quiz-review td {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--tn-line, #e2e8f0);
  vertical-align: top;
  color: var(--tn-ink, #0f172a);
}

.tn-quiz-review tr.success td,
.tn-quiz-review tr.is-ok td {
  background: var(--tn-success-soft, #eaf7f2);
  border-color: rgba(var(--tn-brand-rgb, 22, 99, 78), 0.25);
}

.tn-quiz-review tr.is-picked td {
  background: var(--tn-danger-soft, #fef3f2);
}

.tn-quiz-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
}

.tn-quiz-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.tn-quiz-card-meta__badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tn-quiz-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ——— Final exam taking UI ——— */
body.tk-exam {
  overflow-x: hidden;
  font-family: var(--tk-font, "Poppins", "Noto Sans Arabic", sans-serif);
}

body.tk-exam #main {
  width: 100% !important;
  max-width: 100% !important;
  padding-inline: 0 !important;
  padding-top: 0.75rem !important;
  margin-inline: 0 !important;
}

html[dir="rtl"] body.tk-exam #main,
body.rtl.tk-exam #main {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.tk-exam #side-nav {
  display: none !important;
}

.tn-exam-shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 0.75rem 1.5rem;
}

.tn-exam-panel {
  background: var(--tn-surface, #fff);
  border-radius: 1rem;
  border: 1px solid var(--tn-line, #e2e8f0);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.tn-exam-panel::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--tk-brand-gold, #f0bf77),
    var(--tn-accent, #007AFF)
  );
}

.tn-exam-info {
  margin-bottom: 1.25rem;
}

.tn-exam-info .tn-alert {
  margin-bottom: 1rem;
}

.tn-exam-info ul {
  margin: 0.35rem 0 0.75rem;
  padding-inline-start: 1.2rem;
}

.tn-exam-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--tn-line, #e2e8f0);
  margin-bottom: 1rem;
}

.tn-exam-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.tn-exam-head__icon {
  font-size: 1.5rem;
  color: var(--tn-accent, #007AFF);
  flex-shrink: 0;
}

.tn-exam-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--tn-ink, #0f172a);
}

.tn-exam-abort {
  font-size: 0.85rem;
  color: var(--tn-ink-muted, #64748b);
}

.tn-exam-abort a {
  color: var(--tn-accent, #007AFF);
  font-weight: 600;
}

.tn-exam-timer {
  background: var(--tk-gradient, linear-gradient(135deg, #0066D6, #007AFF));
  color: #fff;
  border-radius: 0.55rem;
  padding: 0.4rem 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(var(--tn-accent-rgb, 0, 122, 255), 0.28);
}

.tn-exam-timer.is-warning {
  background: linear-gradient(135deg, var(--tn-warning-soft, #fff7ed), #fdcb6e);
  color: var(--tn-ink, #0f172a);
}

.tn-exam-timer.is-danger {
  background: linear-gradient(135deg, #fab1a0, var(--tn-danger, #b42318));
  color: #fff;
  animation: tnExamPulse 1s infinite;
}

@keyframes tnExamPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.tn-exam-layout {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.tn-exam-question {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  border-radius: 0.75rem;
  overflow: hidden;
  min-width: 0;
  max-width: 50%;
  border: 1px solid var(--tn-line, #e2e8f0);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.tn-exam-question__head {
  background: var(--tk-gradient, linear-gradient(135deg, #0066D6, #007AFF));
  color: #fff;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
}

.tn-exam-question__head p {
  margin: 0;
}

.tn-exam-question__body {
  background: var(--tn-surface, #fff);
  padding: 0.85rem;
}

.tn-exam-stem {
  display: block;
  margin-bottom: 0.85rem;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--tn-ink, #0f172a);
}

.tn-exam-choice {
  margin: 0 0 0.5rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--tn-line, #e2e8f0);
  border-radius: 0.55rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  color: var(--tn-ink, #0f172a);
  font-weight: 500;
  line-height: 1.4;
}

.tn-exam-choice:hover {
  background: var(--tn-accent-soft, #E8F1FF);
  border-color: rgba(var(--tn-accent-rgb, 0, 122, 255), 0.5);
}

.tn-exam-choice:focus-visible {
  outline: none;
  box-shadow: var(--tn-focus-ring, 0 0 0 3px rgba(0, 122, 255, 0.35));
}

.tn-exam-choice.is-selected,
.tn-exam-choice.selected {
  background: var(--tn-accent-soft, #E8F1FF) !important;
  border-color: var(--tn-accent, #007AFF) !important;
  box-shadow: 0 0 0 1px var(--tn-accent, #007AFF);
  font-weight: 600;
}

.tn-exam-side {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tn-exam-image {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  background: var(--tn-surface-muted, #f8fafc);
  border: 1px solid var(--tn-line, #e2e8f0);
  cursor: zoom-in;
}

.tn-exam-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tn-exam-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.tn-exam-controls__left,
.tn-exam-controls__right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tn-exam-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: var(--tn-ink-muted, #64748b);
  font-size: 0.75rem;
  font-weight: 600;
}

.tn-exam-auto__check {
  color: var(--tn-success, #16634e);
  font-size: 1rem;
}

.tn-exam-overview {
  padding: 0.65rem;
  background: var(--tn-surface-muted, #f8fafc);
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--tn-line, #e2e8f0);
}

.tn-exam-overview > p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
  color: var(--tn-ink-muted, #64748b);
}

.tn-exam-jump-hint {
  margin-inline-start: auto;
  font-size: 0.65rem;
  color: var(--tn-ink-disabled, #94a3b8);
}

.tn-exam-navno,
.queryNo {
  display: inline-block;
  width: 1.7rem;
  height: 1.7rem;
  line-height: 1.7rem;
  text-align: center;
  background: var(--tn-surface, #fff);
  border: 1px solid var(--tn-border-strong, #cbd5e1);
  margin: 2px;
  cursor: pointer;
  border-radius: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tn-ink, #0f172a);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tn-exam-navno:hover,
.queryNo:hover {
  background: var(--tn-accent-soft, #E8F1FF);
  border-color: var(--tn-accent, #007AFF);
}

.tn-exam-navno.focus,
.tn-exam-navno.is-current,
.queryNo.focus {
  background: var(--tk-gradient, linear-gradient(135deg, #0066D6, #007AFF));
  color: #fff;
  border-color: var(--tn-accent, #007AFF);
}

.tn-exam-navno.answered,
.tn-exam-navno.is-answered,
.queryNo.answered {
  background: var(--tn-brand-bright, #50be97);
  color: #fff;
  border-color: var(--tn-brand-bright, #50be97);
}

.tn-exam-navno.flagged,
.tn-exam-navno.is-flagged,
.queryNo.flagged {
  background: var(--tk-brand-gold, #f0bf77);
  color: var(--tn-ink, #0f172a);
  border-color: #e0a85a;
}

.tn-exam-submit-wrap {
  text-align: end;
  padding: 0.5rem 0;
}

.tn-exam-submit-hint {
  font-size: 0.7rem;
  color: var(--tn-ink-disabled, #94a3b8);
  display: block;
  margin-top: 0.35rem;
}

.tn-exam-nav {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tn-exam-nav .tn-btn {
  min-height: 2.4rem;
}

.tn-exam-flag.is-flagged,
.tn-exam-flag.flagged {
  background: var(--tk-brand-gold, #f0bf77) !important;
  border-color: #e0a85a !important;
  color: var(--tn-ink, #0f172a) !important;
}

.tn-exam-review-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tn-exam-swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--tn-ink, #0f172a);
}

.tn-exam-swatch__dot {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.tn-exam-swatch__dot--ok { background: var(--tn-brand-bright, #50be97); }
.tn-exam-swatch__dot--muted { background: var(--tn-ink-disabled, #94a3b8); }
.tn-exam-swatch__dot--flag { background: var(--tk-brand-gold, #f0bf77); }

.tn-exam-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tn-exam-table th,
.tn-exam-table td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--tn-line, #e2e8f0);
  text-align: start;
}

.tn-exam-table thead {
  background: var(--tk-gradient, linear-gradient(135deg, #0066D6, #007AFF));
  color: #fff;
}

.tn-exam-table tr.table-success td,
.tn-exam-table tr.is-answered td {
  background: var(--tn-success-soft, #eaf7f2);
}

.tn-exam-table tr.table-warning td,
.tn-exam-table tr.is-flagged td {
  background: var(--tn-warning-soft, #fff7ed);
}

.tn-exam-review-actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.tn-exam-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--tn-surface, #fff);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
  z-index: 1100;
  width: 400px;
  max-width: 90%;
  text-align: center;
  border-top: 3px solid var(--tk-brand-gold, #f0bf77);
}

.tn-exam-modal h2 {
  margin: 0 0 0.85rem;
  color: var(--tn-ink, #0f172a);
  font-size: 1.35rem;
}

.tn-exam-modal p {
  margin: 0 0 1.25rem;
  color: var(--tn-ink-muted, #64748b);
}

.tn-exam-modal .tn-btn {
  margin: 0 0.25rem;
  min-width: 5rem;
}

.tn-exam-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.72);
  z-index: 1050;
  backdrop-filter: blur(3px);
}

.tn-exam-image-modal {
  display: none;
  position: fixed;
  z-index: 1200;
  inset: 0;
  background: rgba(11, 18, 32, 0.92);
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

.tn-exam-image-modal__img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 0.5rem;
  cursor: default;
}

.tn-exam-image-modal__close {
  position: absolute;
  top: 1.25rem;
  inset-inline-end: 1.75rem;
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  z-index: 1210;
  line-height: 1;
}

.tn-exam-image-modal__close:hover {
  color: var(--tk-brand-gold, #f0bf77);
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#loading-overlay.is-scoring {
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.94));
}

.tn-exam-loading {
  background: var(--tn-surface, #fff);
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  text-align: center;
  max-width: 400px;
  width: 90%;
  border-top: 3px solid var(--tn-accent, #007AFF);
}

.tn-exam-loading--score {
  padding: 2.1rem 1.6rem 1.7rem;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
}

.tn-exam-loading .tk-score-mark {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  background: var(--tk-gradient);
  color: #fff;
  font-size: 1.7rem;
  animation: tnExamScorePulse 1.5s ease-in-out infinite;
}

@keyframes tnExamScorePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--tn-accent-rgb, 0, 122, 255), 0.35); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 14px rgba(var(--tn-accent-rgb, 0, 122, 255), 0); }
}

.tn-exam-spinner {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  border: 3px solid var(--tn-accent-soft, #E8F1FF);
  border-top-color: var(--tn-accent, #007AFF);
  border-radius: 50%;
  animation: tnExamSpin 0.8s linear infinite;
}

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

html[dir="rtl"] .tn-exam-nav .fa-chevron-left,
html[dir="rtl"] .tn-exam-nav .fa-chevron-right,
body.rtl .tn-exam-nav .fa-chevron-left,
body.rtl .tn-exam-nav .fa-chevron-right {
  transform: scaleX(-1);
}

@media (max-width: 768px) {
  .tn-exam-layout {
    flex-direction: column;
  }

  .tn-exam-question,
  .tn-exam-side {
    max-width: 100%;
    flex-basis: 100%;
  }

  .tn-exam-image {
    height: 220px;
  }
}

.tn-quiz-choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tn-quiz-choice-row input[type="text"],
.tn-quiz-choice-row .form-control {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.tn-quiz-correct-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--tn-ink-muted, #64748b);
  white-space: nowrap;
}

.tn-quiz-correct-flag input {
  accent-color: var(--tn-accent, #007AFF);
}

.tn-field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tn-ink, #0f172a);
}

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

.tn-learn-path {
  margin: 0 0 1rem;
}

.tn-learn-path ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--tn-line, #e2e8f0);
  border-radius: var(--tn-radius-md, 0.625rem);
  background: var(--tn-surface, #fff);
  font-size: 0.8125rem;
}

.tn-learn-path li:not(:last-child)::after {
  content: "→";
  margin-inline-start: 0.5rem;
  color: var(--tn-ink-disabled, #94a3b8);
}

.tn-learn-path a {
  color: var(--tn-ink-muted, #475569);
  text-decoration: none;
  font-weight: 600;
}

.tn-learn-path [aria-current="page"] {
  color: var(--tn-ink, #0f172a);
  font-weight: 700;
}

/* ——— Theory library (books list + reader) ——— */
.tn-library {
  --lib-blue: var(--tn-accent, #007AFF);
  --lib-blue-soft: var(--tn-accent-soft, #E8F1FF);
  --lib-gold: #fecc00;
  --lib-gold-brand: var(--tk-brand-gold, #f0bf77);
  --lib-cream: #fffefb;
  --lib-cream-mid: #fff8ee;
  --lib-cream-deep: #fff1db;
  --lib-ink: var(--tn-ink, #0f172a);
  --lib-muted: var(--tn-ink-muted, #64748b);
  --lib-line: rgba(240, 191, 119, 0.42);
  max-width: 72rem;
  margin: 0 auto;
  padding-bottom: 1.5rem;
}

.tn-library__hero {
  padding: 0.5rem 0 1.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}

.tn-library__lede {
  margin: 0.55rem 0 0;
  color: var(--tn-ink-muted, #5a6b7d);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 40rem;
}

.tn-library__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.1rem;
}

.tn-library__note {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.85rem;
  background: var(--lib-cream-mid);
  border: 1px solid var(--lib-line);
  color: var(--lib-ink);
  font-size: 0.88rem;
}

.tn-library__programs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.tn-library__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--lib-line);
  color: var(--lib-ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease;
}

.tn-library__pill:hover {
  background: var(--lib-cream-mid);
  border-color: rgba(240, 191, 119, 0.75);
}

.tn-library__pill.is-active {
  background: linear-gradient(180deg, var(--lib-cream-mid) 0%, var(--lib-cream-deep) 100%);
  border-color: rgba(240, 191, 119, 0.9);
}

.tn-library__search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.tn-library__search .tn-input {
  flex: 1 1 12rem;
  min-height: 2.35rem;
  border-color: var(--lib-line);
  background: #fff;
}

.tn-library__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.tn-library__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--lib-line);
  background: #fff;
  color: var(--lib-ink);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease;
}

.tn-library__chip:hover {
  background: var(--lib-cream-mid);
  border-color: rgba(240, 191, 119, 0.75);
}

.tn-library__chip.is-active {
  background: var(--lib-blue-soft);
  border-color: rgba(0, 122, 255, 0.35);
  color: var(--lib-blue);
}

.tn-library__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .tn-library__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Compact horizontal book rows — whole card is the tap target */
.tn-library__card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem 0.75rem;
  align-items: center;
  min-height: 3.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--lib-line);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--lib-cream) 100%);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 14px rgba(11, 18, 32, 0.04);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.tn-library__card:hover {
  border-color: rgba(0, 122, 255, 0.35);
  box-shadow: 0 8px 20px rgba(11, 18, 32, 0.07);
  background: #fff;
}

.tn-library__card:hover .tn-library__cta-label {
  background: var(--lib-blue);
  color: #fff;
  border-color: var(--lib-blue);
}

.tn-library__card.is-locked {
  opacity: 0.9;
}

.tn-library__icon {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  flex-shrink: 0;
  border-radius: 0.7rem;
  background: var(--lib-blue-soft);
  color: var(--lib-blue);
  border: 1px solid rgba(0, 122, 255, 0.14);
}

.tn-library__icon::before,
.tn-library__icon::after {
  content: none;
  display: none;
}

.tn-library__icon i {
  font-size: 1rem;
  line-height: 1;
  color: var(--lib-blue);
}

.tn-library__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  padding: 0;
}

.tn-library__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--lib-muted);
}

.tn-library__meta > span {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.04);
  color: var(--lib-muted);
}

.tn-library__meta > span:first-child {
  color: var(--lib-blue);
  background: var(--lib-blue-soft);
}

.tn-library__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--lib-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-library__cta-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.6rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(0, 122, 255, 0.28);
  background: rgba(0, 122, 255, 0.08);
  color: var(--lib-blue);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.tn-library__card.is-locked .tn-library__cta-label {
  border-color: rgba(240, 191, 119, 0.55);
  background: rgba(240, 191, 119, 0.22);
  color: #92400e;
}

.tn-library__empty {
  grid-column: 1 / -1;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--lib-muted);
  border: 1px dashed var(--lib-line);
  border-radius: 0.9rem;
  background: var(--lib-cream);
}

/* Reader chrome */
.tn-reader {
  max-width: 72rem;
  margin: 0 auto;
  padding-bottom: 2.5rem;
}

.tn-reader__mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}

.tn-reader__lede {
  margin: 0.45rem 0 0;
  max-width: 42rem;
  color: var(--tn-ink-muted, #5a6b7d);
  font-size: 1.02rem;
  line-height: 1.55;
}

.tn-reader__toc-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.tn-reader__toc-list > li > a {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.55rem 0.4rem;
  border-radius: var(--tn-radius-sm, 0.375rem);
  color: var(--tn-ink, #0f172a);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.35;
}

.tn-reader__toc-list > li > a:hover {
  background: var(--tn-surface-subtle, #e9eef2);
}

.tn-reader__toc-list > li.is-active > a {
  background: var(--tn-accent-soft, #E8F1FF);
  font-weight: 700;
}

.tn-reader__toc-num {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #007AFF;
}

.tn-reader__toc-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tn-ink-muted, #5a6b7d);
}

.tn-reader__toc-list > li.is-locked > a {
  opacity: 0.72;
}

.tn-reader-page .tn-type-section {
  margin: 0.35rem 0 1rem;
}

/* Legacy book card hooks (road signs / older surfaces) */
.tk-book-card {
  border: 1px solid var(--tn-line, #e2e8f0);
  border-radius: var(--tn-radius-lg, 0.875rem);
  background: var(--tn-surface, #fff);
  box-shadow: var(--tn-shadow-xs, 0 1px 2px rgba(11, 18, 32, 0.05));
  overflow: hidden;
}

.tk-book-card .tn-card__footer,
.tk-book-card .card-footer {
  background: transparent !important;
  border: 0 !important;
  padding: 0 1rem 1rem;
}

.tk-library .tk-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.tk-library .tk-search-row .tn-input,
.tk-library .tk-search-row .form-control {
  flex: 1 1 12rem;
  min-height: 2.5rem;
}

/* ——— Program journey & course path (2026 redesign) ——— */
.tn-prog,
.tn-course-path {
  max-width: 52rem;
  margin: 0 auto;
  padding-bottom: 3rem;
}

.tn-prog__hero,
.tn-course-path__head {
  display: grid;
  gap: 1.5rem;
  padding: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
  margin-bottom: 1.75rem;
}

@media (min-width: 768px) {
  .tn-prog__hero,
  .tn-course-path__head {
    grid-template-columns: 1fr minmax(10rem, 14rem);
    align-items: end;
  }
}

.tn-prog__lede,
.tn-course-path__lede {
  margin: 0.5rem 0 0;
  color: var(--tn-ink-muted, #5a6b7d);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 40rem;
}

.tn-prog__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.tn-prog__progress {
  padding: 1rem 1.1rem;
  border: 1px solid var(--tn-border, #dce3ea);
  border-radius: var(--tn-radius-md, 0.5rem);
  background: var(--tn-surface, #fff);
}

.tn-prog__pct {
  margin: 0.25rem 0 0.65rem;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--tn-ink, #12181f);
}

.tn-prog__pct span {
  color: #007AFF;
}

.tn-prog__bar {
  height: 0.4rem;
  border-radius: var(--tn-radius-pill, 999px);
  background: var(--tn-surface-subtle, #e9eef2);
  overflow: hidden;
}

.tn-prog__bar > span {
  display: block;
  height: 100%;
  background: var(--tn-accent, #007AFF);
  border-radius: inherit;
}

.tn-prog__section {
  margin-bottom: 2rem;
}

.tn-prog__section-head {
  margin-bottom: 0.85rem;
}

.tn-prog__path,
.tn-course-path__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--tn-border, #dce3ea);
  border-radius: var(--tn-radius-md, 0.5rem);
  background: var(--tn-surface, #fff);
  overflow: hidden;
}

.tn-prog__step,
.tn-course-path__list > li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}

.tn-prog__step:last-child,
.tn-course-path__list > li:last-child {
  border-bottom: 0;
}

.tn-prog__step.is-current {
  background: var(--tn-accent-soft, #E8F1FF);
}

.tn-prog__index,
.tn-course-path__mark {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tn-radius-sm, 0.375rem);
  background: var(--tn-surface-subtle, #e9eef2);
  color: var(--tn-ink-muted, #5a6b7d);
  font-size: 0.75rem;
  font-weight: 700;
}

.tn-prog__step.is-current .tn-prog__index {
  background: var(--tn-accent, #007AFF);
  color: #fff;
}

.tn-prog__step-body h3,
.tn-course-path__list h3 {
  margin: 0 0 0.15rem;
}

.tn-prog__step-body a,
.tn-course-path__list a {
  color: inherit;
  text-decoration: none;
}

.tn-prog__step-body a:hover,
.tn-course-path__list a:hover {
  color: #007AFF;
}

.tn-prog__exam-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.tn-prog__exam-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--tn-border, #dce3ea);
  border-radius: var(--tn-radius-md, 0.5rem);
  background: var(--tn-surface-inverse, #12181f);
  color: #fff;
}

.tn-prog__exam-list .tn-type-label {
  color: rgba(255, 255, 255, 0.55);
}

.tn-prog__exam-list .tn-type-card {
  color: #fff;
  margin: 0.2rem 0 0;
}

.tn-course-path__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}

.tn-course-path__stats > div {
  padding: 0.75rem;
  border: 1px solid var(--tn-border, #dce3ea);
  border-radius: var(--tn-radius-md, 0.5rem);
  background: var(--tn-surface, #fff);
  text-align: center;
}

.tn-course-path__stats dt {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--tn-ink, #12181f);
}

.tn-course-path__stats dd {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--tn-ink-muted, #5a6b7d);
}

.tn-course-path__section {
  margin-bottom: 1.75rem;
}

.tn-course-path__section--practice {
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--tn-border, #dce3ea);
  border-radius: var(--tn-radius-md, 0.5rem);
  background: var(--tn-surface, #fff);
}

.tn-course-path__list--flat > li {
  grid-template-columns: 1fr auto;
}

.tn-prog__empty,
.tn-course-path__empty {
  grid-column: 1 / -1;
  color: var(--tn-ink-muted, #5a6b7d);
  padding: 1rem 1.1rem;
}

/* Theory reading measure */
.tn-reader-page .tk-prose,
.tn-type-reading {
  max-width: 42rem;
  font-size: 1.0625rem;
  line-height: 1.75;
}

html[dir="rtl"] .tn-reader-page .tk-prose,
body.rtl .tn-reader-page .tk-prose {
  font-family: var(--tn-font-arabic, "Noto Sans Arabic", sans-serif);
}

/* Editorial news / events */
.tn-editorial {
  max-width: 56rem;
  margin: 0 auto;
  padding-bottom: 3rem;
}
.tn-editorial__mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}
.tn-editorial__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.tn-editorial__featured {
  padding: 1.5rem 0 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}
.tn-editorial__featured a {
  color: inherit;
  text-decoration: none;
}
.tn-editorial__dek {
  margin: 0.75rem 0;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--tn-ink-muted, #5a6b7d);
  max-width: 40rem;
}
.tn-editorial__split {
  display: grid;
  gap: 2rem;
}
@media (min-width: 900px) {
  .tn-editorial__split {
    grid-template-columns: 1.2fr 0.8fr;
  }
}
.tn-editorial__list,
.tn-editorial__events {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}
.tn-editorial__list li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}
.tn-editorial__list a,
.tn-editorial__events a {
  color: inherit;
  text-decoration: none;
}
.tn-editorial__events li {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: 0.85rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--tn-border, #dce3ea);
}
.tn-editorial__date {
  text-align: center;
  padding: 0.35rem;
  border-radius: var(--tn-radius-sm, 0.375rem);
  background: var(--tn-surface-subtle, #e9eef2);
}
.tn-editorial__day {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--tn-ink, #12181f);
}
.tn-editorial__mon {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tn-ink-muted, #5a6b7d);
  margin-top: 0.2rem;
}
.tn-editorial__article {
  max-width: 42rem;
}
.tn-editorial__article .tn-type-display {
  margin: 0.35rem 0 0.5rem;
}

/* —— Quiz progress (/quiz/progress/) — compact app list —— */
.tn-qp {
  max-width: 36rem;
  margin: 0 auto;
  padding: 0.35rem 0 1.5rem;
}

.tn-qp__head {
  margin-bottom: 0.85rem;
}

.tn-qp__head-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tn-qp__head h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tn-ink, #0f172a);
  line-height: 1.2;
}

.tn-qp__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  background: var(--tn-accent, #007AFF);
}

.tn-qp__lede {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--tn-ink-muted, #64748b);
}

.tn-qp__section {
  margin: 0 0 0.85rem;
}

.tn-qp__section h2 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tn-ink-muted, #64748b);
}

.tn-qp__cats,
.tn-qp__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.tn-qp__cat {
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.tn-qp__cat-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.tn-qp__cat-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--tn-ink, #0f172a);
  overflow-wrap: anywhere;
}

.tn-qp__cat-pct {
  font-size: 0.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--tn-ink, #0f172a);
}

.tn-qp__cat.is-low .tn-qp__cat-pct { color: #ef4444; }
.tn-qp__cat.is-mid .tn-qp__cat-pct { color: var(--tn-accent, #007AFF); }
.tn-qp__cat.is-high .tn-qp__cat-pct { color: var(--tn-brand-bright, #50be97); }

.tn-qp__bar {
  margin-top: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.tn-qp__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
}

.tn-qp__cat.is-low .tn-qp__bar > span { background: #64748b; }
.tn-qp__cat.is-mid .tn-qp__bar > span { background: var(--tn-accent, #007AFF); }
.tn-qp__cat.is-high .tn-qp__bar > span { background: var(--tn-brand-bright, #50be97); }

.tn-qp__cat-meta {
  margin: 0.28rem 0 0;
  font-size: 0.7rem;
  color: var(--tn-ink-muted, #64748b);
}

.tn-qp__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.45rem 0.55rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-decoration: none;
  color: inherit;
  min-height: 3.1rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tn-qp__row:hover {
  border-color: rgba(0, 122, 255, 0.35);
  background: #f8fbff;
}

.tn-qp__row-main {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.tn-qp__row-title {
  font-size: 0.86rem;
  font-weight: 750;
  color: var(--tn-ink, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-qp__row-meta {
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--tn-ink-muted, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-qp__row-score {
  text-align: end;
  display: grid;
  gap: 0.05rem;
  justify-items: end;
}

.tn-qp__row-score strong {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--tn-ink, #0f172a);
}

.tn-qp__row.is-pass .tn-qp__row-score strong { color: #059669; }
.tn-qp__row.is-fail .tn-qp__row-score strong { color: #dc2626; }

.tn-qp__row-score span {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--tn-ink-muted, #64748b);
}

.tn-qp__row.is-pass .tn-qp__row-score span { color: #059669; }
.tn-qp__row.is-fail .tn-qp__row-score span { color: #dc2626; }

.tn-qp__chev {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #94a3b8;
  border-top: 2px solid #94a3b8;
  transform: rotate(45deg);
  margin-inline-start: 0.1rem;
}

html[dir="rtl"] .tn-qp__chev {
  transform: rotate(-135deg);
}

.tn-qp__empty {
  padding: 1.25rem 0.85rem;
  border-radius: 0.85rem;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-align: center;
}

.tn-qp__empty p {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--tn-ink-muted, #64748b);
}

@media (min-width: 720px) {
  .tn-qp {
    max-width: 40rem;
    padding-top: 0.5rem;
  }

  .tn-qp__head h1 {
    font-size: 1.35rem;
  }

  .tn-qp__cats {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
}

/* —— My courses (/programs/my_courses/) —— */
.tn-myc {
  max-width: 36rem;
  margin: 0 auto;
  padding: 0.35rem 0 1.5rem;
}

.tn-myc__head {
  margin-bottom: 0.85rem;
}

.tn-myc__head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.tn-myc__head h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tn-ink, #0f172a);
}

.tn-myc__lede {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--tn-ink-muted, #64748b);
}

.tn-myc__section {
  margin: 0 0 0.9rem;
}

.tn-myc__section h2 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tn-ink-muted, #64748b);
}

.tn-myc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.tn-myc__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-decoration: none;
  color: inherit;
  min-height: 3rem;
}

.tn-myc__row:hover {
  border-color: rgba(0, 122, 255, 0.35);
  background: #f8fbff;
}

.tn-myc__row-main {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.tn-myc__title {
  font-size: 0.88rem;
  font-weight: 750;
  color: var(--tn-ink, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tn-myc__meta {
  font-size: 0.7rem;
  color: var(--tn-ink-muted, #64748b);
}

.tn-myc__chev {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #94a3b8;
  border-top: 2px solid #94a3b8;
  transform: rotate(45deg);
}

html[dir="rtl"] .tn-myc__chev {
  transform: rotate(-135deg);
}

.tn-myc__empty {
  padding: 1.1rem 0.85rem;
  border-radius: 0.85rem;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-align: center;
}

.tn-myc__empty p {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  color: var(--tn-ink-muted, #64748b);
}

@media (min-width: 720px) {
  .tn-myc {
    max-width: 40rem;
  }

  .tn-myc__head h1 {
    font-size: 1.35rem;
  }
}

/* ——— Course training video speed (up to 2.5×) ——— */
.tn-video-player {
  margin-bottom: 1rem;
}

.tn-video-player__frame {
  border-radius: 0.75rem;
  overflow: hidden;
  background: #0f172a;
}

.tn-video-player__frame video {
  width: 100%;
  height: 100%;
  display: block;
}

.tn-video-speed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.65rem;
  background: var(--tn-surface, #fff);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.tn-video-speed__label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--tn-ink-muted, #64748b);
  margin-inline-end: 0.15rem;
}

.tn-video-speed__opts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tn-video-speed__btn {
  appearance: none;
  border: 1px solid var(--tn-line, #e2e8f0);
  background: #fff;
  color: var(--tn-ink, #0f172a);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 0.42rem 0.55rem;
  min-height: 2rem;
  border-radius: 0.45rem;
  cursor: pointer;
  touch-action: manipulation;
}

.tn-video-speed__btn:hover {
  border-color: rgba(0, 122, 255, 0.45);
  background: var(--tn-accent-soft, #E8F1FF);
}

.tn-video-speed__btn.is-active {
  border-color: var(--tn-accent, #007AFF);
  background: var(--tn-accent, #007AFF);
  color: #fff;
}

.tn-video-speed__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.28);
}
