/* Lesson view — full-screen reading: a slim top bar, one centred column, and a slide-over
   contents drawer that can switch lessons and modules. Site header/footer are hidden
   while a lesson is open (body.in-lesson). Scoped under .pr-lesson. */
body.in-lesson .site-header, body.in-lesson .site-footer { display: none; }
body.in-lesson main.container { max-width: none; padding: 0; }
:root { --lbar-h: 60px; }

/* ---- top bar ---- */
.prl-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: var(--lbar-h); padding: 0 20px;
  background: var(--header-bg); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px); }
.prl-bar-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 40px; padding: 0 14px; border-radius: 12px;
  background: var(--subtle); font-size: 14.5px; font-weight: 600; color: var(--text); white-space: nowrap; transition: background .15s, transform .12s; }
.prl-bar-btn:hover:not(:disabled) { background: var(--line); }
.prl-bar-btn:active:not(:disabled) { transform: scale(.97); }
.prl-bar-btn:disabled { opacity: .35; cursor: default; }
.prl-bar-icon { width: 40px; padding: 0; }
.prl-bar-exit { background: none; padding: 0 12px; color: var(--text-2); }
.prl-bar-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.prl-bar-mod { flex: none; font-size: 12.5px; font-weight: 700; background: var(--brand); color: var(--on-brand); border-radius: 999px; padding: 3px 10px; }
.prl-bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; letter-spacing: -0.01em; }
.prl-bar-step { flex: none; font-size: 13.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.prl-burger { width: 16px; height: 2px; border-radius: 1px; background: currentColor; box-shadow: 0 5px 0 currentColor, 0 -5px 0 currentColor; }
.prl-chev { width: 9px; height: 9px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.prl-chev-l { transform: rotate(45deg); margin-left: 3px; }
.prl-chev-r { transform: rotate(-135deg); margin-right: 3px; }
.prl-x { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--subtle); flex: none; }
.prl-x::before, .prl-x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2px; border-radius: 1px; background: var(--text); }
.prl-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.prl-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.prl-x-sm { width: 20px; height: 20px; background: none; }
.prl-x-sm::before, .prl-x-sm::after { width: 12px; background: currentColor; }
.prl-bar .prl-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; margin: 0; border-radius: 0; background: transparent; }
.prl-bar .prl-progress i { border-radius: 0 2px 2px 0; }

/* ---- contents drawer ---- */
.prl-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(10, 10, 12, .45); }
.prl-drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(440px, 92vw); display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--line); transform: translateX(-102%); visibility: hidden;
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s .26s; }
.prl-drawer.is-open { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.prl-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; font-size: 18px; letter-spacing: -0.02em; }
.prl-modsel { display: grid; gap: 6px; padding: 8px 20px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.prl-modsel select { width: 100%; height: 44px; font-size: 15px; font-weight: 500; border-radius: 12px; }
.prl-drawer-body { flex: 1; overflow-y: auto; padding: 0 12px 28px; overscroll-behavior: contain; }


/* ---- lessons / steps list (inside the drawer) ---- */
.prl-lessons, .prl-steps { list-style: none; }
.prl-lesson-link { display: flex; align-items: center; gap: 12px; width: 100%; border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 15px; text-align: left; transition: background .15s; }
.prl-lesson-link:hover { background: var(--subtle); }
.prl-lesson-item.is-current > .prl-lesson-link { font-weight: 700; background: var(--tint-lilac); }
.prl-lnum { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; background: var(--subtle); color: var(--text-3); }
.prl-lesson-item.is-current .prl-lnum { background: var(--bg); color: var(--text); }
.prl-lesson-item.is-done .prl-lnum { background: var(--brand); color: var(--on-brand); }
.prl-lname { flex: 1; line-height: 1.35; }
.prl-lscore { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.prl-lesson-item.is-done .prl-lscore { color: var(--ok); }
.prl-steps { margin: 4px 0 10px 25px; padding-left: 14px; border-left: 1px solid var(--line); }
.prl-step-link { display: flex; align-items: center; gap: 10px; width: 100%; border-radius: 8px;
  padding: 7px 10px; font-size: 14px; line-height: 1.35; color: var(--text-3); text-align: left; }
.prl-step-link:hover { background: var(--subtle); color: var(--text); }
.prl-step-link.is-active { color: var(--text); font-weight: 600; }
.prl-step-link.is-done { color: var(--text-2); }
.prl-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.prl-step-link.is-done .prl-dot { background: var(--ok); border-color: var(--ok); }
.prl-step-link.is-current .prl-dot, .prl-step-link.is-active .prl-dot { border-color: var(--accent); background: var(--accent); }

/* ---- main column ---- */
.prl-main { max-width: 860px; margin: 0 auto; padding: 44px 24px 140px; min-width: 0; }
.prl-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--text-3); margin-bottom: 20px; }
.prl-sep { color: var(--line-strong); }
.prl-crumb-cur { color: var(--text-2); }
.prl-link { padding: 0; font: inherit; color: var(--text-3); text-align: left; }
.prl-link:hover { color: var(--text); text-decoration: underline; }
.prl-title { font-size: 42px; line-height: 1.08; font-weight: 800; letter-spacing: -0.035em; margin-bottom: 14px; }
.prl-meta { font-size: 14px; color: var(--text-3); margin-bottom: 14px; }
.prl-progress { height: 8px; background: var(--subtle); border-radius: 4px; overflow: hidden; margin-bottom: 40px; }
.prl-progress i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .35s; }

/* ---- theory steps ---- */
.prl-step { scroll-margin-top: calc(var(--lbar-h) + 24px); padding-bottom: 36px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }
.prl-step.is-done .prl-kicker::after { content: " · done"; color: var(--ok); }
.prl-kicker { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--subtle); border-radius: 999px; padding: 4px 12px; margin-bottom: 12px; }
.prl-h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 18px; }
.prl-p { font-size: 17.5px; line-height: 1.7; margin: 0 0 18px; }
.prl-ul { margin: 0 0 18px; padding-left: 24px; }
.prl-ul li { font-size: 17px; line-height: 1.7; margin-bottom: 6px; }
.prl-formula { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 19px; line-height: 1.8;
  text-align: center; margin: 8px 0 22px; color: var(--text); overflow-x: auto; overflow-wrap: anywhere; }
.prl-code { position: relative; margin: 6px 0 22px; }
.prl-code pre { background: var(--subtle); border-radius: 16px; padding: 18px 88px 18px 20px;
  overflow-x: auto; font: 14px/1.65 var(--mono); margin: 0; }
.prl-copy { position: absolute; top: 8px; right: 8px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; font-size: 12.5px; color: var(--text-2); }
.prl-copy:hover { color: var(--text); border-color: var(--line-strong); }
/* syntax tokens (msHl) — light theme mirrors the lesson-reader palette */
.prl-code .tk-k { color: #067d17; font-weight: 600; }   /* keyword */
.prl-code .tk-s { color: #ba2121; }                     /* string */
.prl-code .tk-c { color: #8a8a93; font-style: italic; } /* comment */
.prl-code .tk-n { color: #1750eb; }                     /* number */
.prl-code .tk-d { color: #9a6e3a; }                     /* decorator */
.prl-code .tk-t { color: #116329; }                     /* html tag */
.prl-code .tk-a { color: #6f42c1; }                     /* html attr */
:root[data-theme="dark"] .prl-code .tk-k { color: #7ee787; }
:root[data-theme="dark"] .prl-code .tk-s { color: #ffa198; }
:root[data-theme="dark"] .prl-code .tk-c { color: #8b949e; }
:root[data-theme="dark"] .prl-code .tk-n { color: #79c0ff; }
:root[data-theme="dark"] .prl-code .tk-d { color: #d2a8ff; }
:root[data-theme="dark"] .prl-code .tk-t { color: #7ee787; }
:root[data-theme="dark"] .prl-code .tk-a { color: #79c0ff; }
.prl-note { background: var(--tint-yellow); border-radius: 18px; padding: 16px 20px; margin: 8px 0 24px; font-size: 16px; line-height: 1.65; color: var(--text); }
.prl-note-label { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
/* try-this prompts (were ✅ emoji stickers in the source) — CSS check chip, no emoji */
.prl-try { background: var(--subtle); border-left: 3px solid var(--brand); border-radius: var(--radius-sm); }
.prl-try > div { display: flex; gap: 12px; align-items: flex-start; }
.prl-try > div::before { content: ""; flex: none; width: 7px; height: 13px; margin-top: 4px;
  border-right: 2.5px solid var(--brand); border-bottom: 2.5px solid var(--brand);
  transform: rotate(45deg); }

/* ---- buttons ---- */
.prl-actions { display: flex; gap: 10px; margin-top: 10px; }
.prl-tools .prl-btn { background: var(--subtle); color: var(--text); font-weight: 600; }
.prl-tools .prl-btn:hover { background: var(--line); color: var(--text); }
.prl-btn { font: inherit; font-weight: 600; font-size: 15px; border-radius: 14px; padding: 13px 24px;
  border: 1px solid transparent; transition: background .12s, border-color .12s, color .12s, transform .12s; }
.prl-primary { background: var(--brand); color: var(--on-brand); }
.prl-primary:hover:not(:disabled) { background: var(--brand-hover); }
.prl-primary:disabled { background: var(--line-strong); cursor: default; }
.prl-secondary { background: var(--brand); color: var(--on-brand); }
.prl-secondary:hover:not(:disabled) { background: var(--brand-hover); }
.prl-secondary.is-on, .prl-secondary:disabled { background: var(--subtle); color: var(--ok); border-color: transparent; cursor: default; }
.prl-ghost { color: var(--text-3); font-weight: 500; font-size: 14px; }
.prl-ghost:hover { color: var(--err); }

/* ---- quiz ---- */
.prl-quiz { border-bottom: 0; }
.prl-quiz-card { background: var(--tint-lilac); border-radius: var(--radius-xl); padding: 30px 34px; }
.prl-quiz-label { font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 10px; }
.prl-quiz-q { font-size: 20px; line-height: 1.4; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 18px; }
.prl-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.prl-opt { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; background: var(--bg);
  border: 1px solid transparent; border-radius: 14px; padding: 13px 16px; font-size: 16px; line-height: 1.5;
  transition: border-color .12s, background .12s; }
.prl-opt:hover:not(:disabled) { border-color: var(--line-strong); }
.prl-radio { position: relative; width: 18px; height: 18px; margin-top: 3px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong); transition: .12s; }
.prl-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; transition: .12s; }
.prl-opt.is-sel { border-color: var(--text); }
.prl-opt.is-sel .prl-radio { border-color: var(--text); }
.prl-opt.is-sel .prl-radio::after { background: var(--text); }
.prl-opt.is-ok { border-color: var(--ok); }
.prl-opt.is-ok .prl-radio { border-color: var(--ok); }
.prl-opt.is-ok .prl-radio::after { background: var(--ok); }
.prl-opt.is-bad { border-color: var(--line); color: var(--text-3); }
.prl-opt.is-bad .prl-radio { border-color: var(--err); }
.prl-opt:disabled { cursor: default; }
.prl-result { margin-top: 14px; font-size: 15.5px; line-height: 1.6; }
.prl-result:empty { display: none; }
.prl-result.is-ok { border-left: 2px solid var(--ok); padding-left: 14px; }
.prl-result.is-ok b { color: var(--ok); }
.prl-result.is-bad, .prl-result.is-bad b { color: var(--err); }

/* ---- end of lesson ---- */
.prl-end { margin-top: 8px; }
.prl-end-card { color: var(--on-brand); background: var(--brand); border-radius: var(--radius-xl); padding: 36px; margin-bottom: 24px; }
.prl-end-card .prl-h2 { font-size: 32px; }
.prl-end-card .prl-quiz-label, .prl-end-card .prl-muted { color: var(--on-brand-2); }
.prl-end-card .prl-primary { background: #141414; color: #fff; border-color: transparent; }
.prl-end-card .prl-primary:hover:not(:disabled) { background: #2c2c30; }
.prl-end-card .prl-ghost { background: rgba(255, 255, 255, .85); color: var(--brand); }
.prl-end-card .prl-ghost:hover { background: #fff; color: var(--brand); }
.prl-end-card .prl-exlist .prl-link { color: var(--on-brand); }
.prl-muted { color: var(--text-2); font-size: 16px; margin: 0 0 14px; }
.prl-exlist { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; font-size: 14px; }
.prl-exlist .prl-link { color: var(--accent); font-family: var(--mono); font-size: 13px; }
.prl-refs { border-top: 1px solid var(--line); padding: 18px 0; margin-bottom: 12px; }
.prl-refs h4 { font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 10px; }
.prl-refs a { display: block; color: var(--text); text-decoration: none; font-size: 15px; padding: 5px 0; }
.prl-refs a:hover { color: var(--accent); }
.prl-endnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 24px; }

/* ---- mobile ---- */
@media (max-width: 900px) {
  .prl-bar { padding: 0 12px; gap: 8px; }
  .prl-bar-label, .prl-bar-name { display: none; }
  .prl-bar-title { flex: 1; }
  .prl-main { padding: 28px 16px 120px; }
  .prl-title { font-size: 30px; }
  .prl-p, .prl-ul li { font-size: 16.5px; }
  .prl-formula { font-size: 16px; text-align: left; }
  .prl-code pre { padding-right: 60px; }
  .prl-quiz-card, .prl-end-card { padding: 20px; }
}

/* markdown-rendered lesson sections (msmd.js) */
.prl-md .prl-h { margin: 18px 0 10px; }
.prl-md h3.prl-h { font-size: 19px; }
.prl-md h4.prl-h, .prl-md h5.prl-h, .prl-md h6.prl-h { font-size: 16px; color: var(--text-2); }
.prl-img { max-width: 100%; height: auto; border-radius: 16px; display: block; margin: 14px 0; background: #fff; border: 1px solid var(--line); }
.prl-table { border-collapse: collapse; margin: 10px 0 20px; font-size: 15px; display: block; overflow-x: auto; }
.prl-table th, .prl-table td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.prl-table th { background: var(--subtle); font-weight: 600; }
.prl-tex { font-family: var(--mono, monospace); font-size: 0.95em; }
