/* ==========================================================================
   LMS · base + student styles
   Brand colors come from Admin → Settings (CSS variables --brand / --accent).
   ========================================================================== */

:root {
  --brand: #5B21B6;
  --brand-rgb: 91, 33, 182;
  --accent: #FFD84D;
  --accent-rgb: 255, 216, 77;
  --ink: #1E0B3D;
  --text: #2E2640;
  --muted: #6B6480;
  --line: #E8E3F1;
  --line-strong: #D9D1E8;
  --bg: #F7F5FB;
  --card: #ffffff;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --danger: #c2410c;
  --danger-bg: #fff4ed;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 22, 29, .04), 0 4px 16px rgba(18, 22, 29, .05);
  --shadow-lg: 0 10px 40px rgba(18, 22, 29, .12);
  --topbar: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.015em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
code { background: #F0ECF7; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.ic { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin: 0 0 8px; }
[hidden] { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 700; font-size: 15px; line-height: 1;
  cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s;
  background: #fff; color: var(--ink); border-color: var(--line-strong);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 6px 18px rgba(var(--brand-rgb), .22); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-accent { background: var(--accent); color: #1E0B3D; border-color: var(--accent); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-ghost-light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-ghost { background: #fff; color: var(--danger); border-color: #f3c7b0; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 52px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: rgba(0,0,0,.05); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: 14px; font-weight: 600; color: var(--ink); }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field small { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .12); }
input:disabled { background: #F3F0F9; color: var(--muted); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 50px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.link-sm { font-size: 13px; font-weight: 600; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 14px; }
legend { font-weight: 800; color: var(--ink); margin-bottom: 4px; padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex-shrink: 0; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fed7aa; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bfdbfe; }

/* ---------- Brand ---------- */
.brand-text { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--ink); letter-spacing: -.01em; line-height: 1.15; }
.brand-text.on-dark { color: #fff; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--brand)); flex-shrink: 0; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.brand-logo { max-height: 38px; width: auto; }

/* ==========================================================================
   Auth pages (login, enroll, reset, thank-you)
   ========================================================================== */
.auth-body { background: var(--bg); }
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.auth-side { display: none; }
.auth-main { display: flex; flex-direction: column; align-items: center; padding: 20px 16px calc(24px + var(--safe-b)); }
.auth-mobile-brand { width: 100%; max-width: 440px; padding: 6px 2px 18px; }
.auth-mobile-brand a { text-decoration: none; }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 26px 20px; box-shadow: var(--shadow); }
.auth-title { font-size: 1.6rem; margin-bottom: 6px; }
.auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-alt { text-align: center; margin: 18px 0 0; font-size: 14px; color: var(--muted); }
.auth-alt a { font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.auth-foot { margin-top: auto; padding-top: 24px; font-size: 12px; color: var(--muted); }
.state-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: rgba(var(--brand-rgb), .1); color: var(--brand); margin-bottom: 16px; }
.state-icon.big { width: 72px; height: 72px; border-radius: 50%; margin: 4px auto 18px; }
.state-icon.success { background: var(--success-bg); color: var(--success); }
.state-icon.warn { background: var(--warn-bg); color: var(--warn); }
.thankyou-page .auth-title, .thankyou-page .auth-sub { text-align: center; }
.note-box { display: flex; gap: 10px; align-items: flex-start; background: #F8F6FC; border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px; font-size: 14px; color: var(--text); }
.note-box .ic { color: var(--brand); margin-top: 2px; }
.dupe-actions { display: flex; gap: 10px; margin: -6px 0 18px; }
.dupe-actions .btn { flex: 1; }

@media (min-width: 960px) {
  .auth-shell { grid-template-columns: minmax(380px, 46%) 1fr; }
  .auth-side {
    display: block; position: relative; overflow: hidden; color: #fff;
    background:
      radial-gradient(90% 60% at 100% 0%, rgba(var(--accent-rgb), .18), transparent 60%),
      linear-gradient(160deg, var(--brand) 0%, #3B0F7A 55%, #24074F 100%);
  }
  .auth-side::after {
    content: ""; position: absolute; inset: 0; opacity: .08;
    background-image: linear-gradient(rgba(255,255,255,1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,1) 1px, transparent 1px);
    background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
  }
  .auth-side-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 44px 52px; }
  .auth-brand { text-decoration: none !important; }
  .auth-pitch { margin: auto 0; max-width: 460px; }
  .auth-pitch .eyebrow { color: var(--accent); }
  .auth-pitch h2 { color: #fff; font-size: clamp(2rem, 1.4rem + 1.6vw, 2.9rem); font-weight: 800; line-height: 1.08; margin-bottom: 16px; }
  .auth-pitch p { color: #DCCBFF; font-size: 17px; }
  .auth-coach { color: rgba(255,255,255,.7); font-weight: 600; margin: 0; }
  .auth-main { justify-content: center; padding: 40px; }
  .auth-mobile-brand { display: none; }
  .auth-card { padding: 36px 34px; }
  .auth-foot { margin-top: 0; }
}

/* ---------- Installer ---------- */
.install-body { background: var(--bg); }
.install-wrap { max-width: 640px; margin: 0 auto; padding: 28px 16px 60px; }
.install-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px 20px; box-shadow: var(--shadow); }
.install-card fieldset { padding: 18px 0; border-top: 1px solid var(--line); }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; font-size: 14px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist .ok { color: var(--success); }
.checklist .bad { color: var(--danger); font-weight: 700; }
@media (min-width: 640px) { .install-card { padding: 36px; } }

/* ==========================================================================
   Student area
   ========================================================================== */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { height: var(--topbar); max-width: 1320px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-brand { min-width: 0; text-decoration: none !important; }
.topbar-brand .brand-text { font-size: 15px; }
.topbar-brand .brand-text { max-width: 54vw; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-progress { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ring { --p: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--p) * 1%), #EAE5F3 0); }
.ring span { width: 28px; height: 28px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--ink); }
.topbar-progress-label { display: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; background: var(--brand); }
.avatar-btn { display: flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: .15s; }
.menu.open .menu-pop { opacity: 1; visibility: visible; transform: none; }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; }
.menu-head strong { color: var(--ink); }
.menu-head span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; color: var(--ink); font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-decoration: none !important; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: #F4F1FA; }
.menu-pop .ic { color: var(--muted); }
@media (min-width: 640px) { .topbar-progress-label { display: inline; } .topbar-inner { padding: 0 24px; } }

.container { max-width: 1080px; margin: 0 auto; padding: 18px 16px 56px; }
.container.narrow { max-width: 680px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }

/* Dashboard */
.dash-hero { display: grid; gap: 14px; margin-bottom: 16px; }
.dash-hero-text { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow); }
.dash-hero-text h1 { margin-bottom: 8px; }
.dash-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.dash-stats div { background: #F8F6FC; border-radius: 12px; padding: 12px; }
.dash-stats strong { display: block; font-size: 1.35rem; color: var(--ink); line-height: 1.1; }
.dash-stats span { font-size: 12px; color: var(--muted); font-weight: 600; }
.dash-progress-card { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 22px 18px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 18px; align-items: center; }
.dash-progress-card .muted { color: rgba(255,255,255,.65); margin: 6px 0 0; }
.big-ring { --p: 0; grid-row: span 2; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,.12) 0); }
.big-ring > div { width: 78px; height: 78px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; align-content: center; text-align: center; }
.big-ring strong { font-size: 22px; line-height: 1; }
.big-ring span { font-size: 11px; color: rgba(255,255,255,.65); }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; align-self: end; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }
.bar.slim { background: #ECE8F4; height: 6px; margin: 8px 0 4px; max-width: 320px; }
.bar.slim span { background: var(--brand); }
@media (min-width: 860px) {
  .dash-hero { grid-template-columns: 1.7fr 1fr; }
  .dash-hero-text, .dash-progress-card { padding: 28px; }
  .dash-progress-card { grid-template-columns: 1fr; grid-template-rows: auto; justify-items: center; text-align: center; align-content: center; gap: 14px; }
  .big-ring { grid-row: auto; width: 132px; height: 132px; }
  .big-ring > div { width: 108px; height: 108px; }
  .big-ring strong { font-size: 30px; }
  .dash-progress-card .bar { width: 100%; }
}

.resume-card { display: grid; grid-template-columns: 1fr; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 22px; color: inherit; text-decoration: none !important; transition: box-shadow .2s, transform .2s; }
.resume-card:hover { box-shadow: var(--shadow-lg); }
.resume-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--ink); overflow: hidden; }
.resume-thumb img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.34); }
.resume-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.45)); }
.resume-thumb-icon { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.4); }
.resume-play { position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: #1E0B3D; display: grid; place-items: center; box-shadow: 0 8px 26px rgba(0,0,0,.35); }
.resume-play .ic { margin-left: 3px; }
.resume-body { padding: 18px; }
.resume-body h2 { font-size: 1.15rem; margin-bottom: 4px; }
.resume-body .btn { margin-top: 12px; }
@media (min-width: 720px) {
  .resume-card { grid-template-columns: 300px 1fr; }
  .resume-thumb { aspect-ratio: auto; min-height: 170px; }
  .resume-body { padding: 22px 24px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
}

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.section-head h2 { margin: 0; }
.module { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden; }
.module > summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 16px; cursor: pointer; user-select: none; }
.module > summary::-webkit-details-marker { display: none; }
.module-num { width: 40px; height: 40px; border-radius: 12px; background: #F3F0F9; color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.module.is-complete .module-num { background: var(--success-bg); color: var(--success); }
.module-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.module-meta strong { color: var(--ink); font-size: 15.5px; line-height: 1.3; }
.module-meta .small { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.module-chev { color: var(--muted); transition: transform .2s; }
.module[open] .module-chev { transform: rotate(180deg); }
.mini-bar { height: 3px; background: #F0ECF7; margin: 0 16px; border-radius: 3px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: var(--brand); }
.lesson-list { list-style: none; margin: 0; padding: 8px; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; color: var(--text); text-decoration: none !important; min-height: 52px; }
.lesson-row:hover { background: #F7F4FC; }
.lesson-row.current { background: rgba(var(--brand-rgb), .07); }
.lesson-row.current .lesson-title { color: var(--brand); font-weight: 700; }
.lesson-status { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.done .lesson-status { background: var(--success); border-color: var(--success); }
.lesson-title { flex: 1; min-width: 0; font-weight: 500; line-height: 1.35; }
.lesson-type { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.lesson-type span { display: none; }
@media (min-width: 640px) { .lesson-type span { display: inline; } .container { padding: 26px 24px 64px; } .module > summary { padding: 18px 20px; } .mini-bar { margin: 0 20px; } }
.empty { padding: 30px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 20px; }
.profile-head h1 { font-size: 1.4rem; margin: 0 0 2px; }
.profile-head p { margin: 0; }
.card h2 { margin-bottom: 14px; }

/* ==========================================================================
   Lesson page
   ========================================================================== */
.page-lesson { padding-bottom: calc(76px + var(--safe-b)); }
.lesson-layout { max-width: 1320px; margin: 0 auto; }
.lesson-main { min-width: 0; padding: 0 0 30px; }
.crumbs { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.crumbs a { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; flex-shrink: 0; }
.crumb-module { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-main > .alert { margin: 0 16px 12px; }
.lesson-media { background: #000; }
.lesson-head { padding: 18px 16px 6px; }
.lesson-head h1 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.85rem); margin-bottom: 14px; }
.lesson-head .eyebrow { color: var(--muted); }
.lesson-actions { display: none; gap: 10px; flex-wrap: wrap; }
.complete-btn { background: #fff; border: 1px solid var(--line-strong); color: var(--ink); }
.complete-btn .when-done { display: none; }
.complete-btn.is-done { background: var(--success-bg); border-color: #a7f3c0; color: var(--success); }
.complete-btn.is-done .when-done { display: inline-flex; align-items: center; gap: 8px; }
.complete-btn.is-done .when-todo { display: none; }
.complete-btn .when-todo { display: inline-flex; align-items: center; gap: 8px; }
.prose { padding: 4px 16px 10px; max-width: 760px; font-size: 16px; line-height: 1.7; }
.prose a { text-decoration: underline; word-break: break-word; }
.prose h2, .prose h3 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose blockquote { margin: 1em 0; padding: 8px 16px; border-left: 3px solid var(--accent); background: #fff; border-radius: 0 10px 10px 0; }
.lesson-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 16px 0; }
.pager { display: flex; align-items: center; gap: 10px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none !important; min-width: 0; transition: border-color .15s; }
.pager:hover { border-color: var(--brand); }
.pager > span { display: grid; gap: 2px; min-width: 0; font-weight: 600; font-size: 14px; line-height: 1.3; }
.pager-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 719px) { .lesson-pager { grid-template-columns: 1fr; } .pager-empty { display: none; } }
.pager small { display: block; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.pager.next { justify-content: flex-end; text-align: right; }
.pager .ic { color: var(--brand); }

.coming-soon { background: #fff; padding: 36px 20px; text-align: center; display: grid; justify-items: center; border-bottom: 1px solid var(--line); }
.coming-soon h3 { margin: 4px 0 6px; }
.coming-soon p { max-width: 420px; margin: 0; }

/* Course drawer (mobile/tablet) → sidebar (desktop) */
.lesson-side { position: fixed; z-index: 80; left: 0; right: 0; bottom: 0; max-height: 84vh; max-height: 84dvh; background: #fff; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.18); transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; padding-bottom: var(--safe-b); }
.drawer-open .lesson-side { transform: none; }
.drawer-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(10,12,16,.45); opacity: 0; visibility: hidden; transition: .25s; }
.drawer-open .drawer-scrim { opacity: 1; visibility: visible; }
.drawer-open { overflow: hidden; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 12px 18px; border-bottom: 1px solid var(--line); position: relative; }
.side-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: #DED7EA; }
.side-head > div { display: grid; }
.side-head strong { color: var(--ink); }
.side-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 6px 8px 16px; }
.side-module { border-bottom: 1px solid var(--line); }
.side-module:last-child { border-bottom: 0; }
.side-module > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 10px; cursor: pointer; }
.side-module > summary::-webkit-details-marker { display: none; }
.side-module > summary > span { display: grid; gap: 1px; min-width: 0; }
.side-module > summary strong { font-size: 14px; color: var(--ink); line-height: 1.3; }
.side-module > summary .ic { color: var(--muted); transition: transform .2s; }
.side-module[open] > summary .ic { transform: rotate(180deg); }
.side-module ol { list-style: none; margin: 0 0 10px; padding: 0; }
.side-lesson { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--text); font-size: 14px; line-height: 1.35; text-decoration: none !important; min-height: 44px; }
.side-lesson:hover { background: #F6F3FB; }
.side-lesson.current { background: rgba(var(--brand-rgb), .09); color: var(--brand); font-weight: 700; }
.side-lesson .lesson-status { width: 20px; height: 20px; }
.side-lesson-title { flex: 1; min-width: 0; }
.side-lesson-type { color: var(--muted); }

/* Bottom bar (mobile) */
.mobile-bar { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 10px 12px calc(10px + var(--safe-b)); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.mb-btn { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); display: grid; place-items: center; flex-shrink: 0; cursor: pointer; }
.mb-btn.disabled { opacity: .35; }
.mb-main { flex: 1; min-height: 48px; border-radius: 12px; font: inherit; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; cursor: pointer; }

@media (min-width: 720px) {
  .lesson-media { border-radius: var(--radius); overflow: hidden; margin: 0 16px; box-shadow: var(--shadow-lg); }
  .coming-soon { border: 1px solid var(--line); border-radius: var(--radius); }
  .lesson-media:has(.coming-soon) { background: transparent; box-shadow: none; }
  .lesson-head { padding: 22px 16px 6px; }
}
@media (min-width: 1100px) {
  .page-lesson { padding-bottom: 0; }
  .mobile-bar { display: none; }
  .lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0; }
  .lesson-main { padding: 0 28px 48px 24px; }
  .crumbs { padding: 18px 0 14px; }
  .lesson-main > .alert { margin: 0 0 12px; }
  .lesson-media { margin: 0; }
  .lesson-head, .prose, .lesson-pager { padding-left: 0; padding-right: 0; }
  .lesson-actions { display: flex; }
  .outline-toggle { display: none; }
  .lesson-side { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); max-height: none; transform: none; border-radius: 0; box-shadow: none; border-left: 1px solid var(--line); z-index: 1; padding-bottom: 0; }
  .side-head::before, .side-close, .drawer-scrim { display: none; }
  .drawer-open { overflow: auto; }
}

/* ==========================================================================
   Video player (YouTube without YouTube branding)
   The iframe is 3x taller than the visible stage and shifted up, so YouTube's title bar
   and logo sit outside the visible area. A transparent shield blocks clicks to YouTube.
   ========================================================================== */
.vplayer { position: relative; background: #000; outline: none; user-select: none; -webkit-user-select: none; }
.vp-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #000; }
@supports not (aspect-ratio: 16 / 9) { .vp-stage { height: 0; padding-top: 56.25%; } }
.vp-frame { position: absolute; left: 0; top: -100%; width: 100%; height: 300%; pointer-events: none; }
.vp-frame iframe, .vp-target { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.vp-shield { position: absolute; inset: 0; z-index: 2; cursor: pointer; }
.vp-poster { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background-color: #000; background-size: cover; background-position: center; cursor: pointer; }
.vp-poster::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(0,0,0,.15), rgba(0,0,0,.55)); }
.vp-bigplay { position: relative; width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--accent); color: #1E0B3D; display: grid; place-items: center; cursor: pointer; box-shadow: 0 10px 34px rgba(0,0,0,.4); transition: transform .15s; }
.vp-bigplay .ic { margin-left: 4px; }
.vp-bigplay:hover { transform: scale(1.06); }
.vp-bigplay.small { width: 64px; height: 64px; background: rgba(255,255,255,.92); }
.vp-resume { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 99px; white-space: nowrap; }
.vp-paused { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(0,0,0,.35); pointer-events: none; }
.vp-paused .vp-bigplay { pointer-events: auto; }
.vp-ended { position: absolute; inset: 0; z-index: 7; background: rgba(8,10,14,.92); color: #fff; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 16px; }
.vp-ended p { margin: 0; font-weight: 700; font-size: 17px; }
.vp-ended-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.vp-spinner { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none; }
.vp-spinner span, .spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner { width: 22px; height: 22px; border-color: rgba(0,0,0,.12); border-top-color: var(--brand); display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.vp-unmute { position: absolute; z-index: 5; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 0; border-radius: 99px; background: rgba(0,0,0,.72); color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }

.vp-controls { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; padding: 26px 8px 4px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.78)); color: #fff; transition: opacity .25s; }
.vplayer.is-playing.is-idle .vp-controls { opacity: 0; pointer-events: none; }
.vplayer.is-playing.is-idle .vp-stage { cursor: none; }
.vplayer:not(.has-started) .vp-controls { display: none; }
.vp-row { display: flex; align-items: center; gap: 2px; }
.vp-btn { position: relative; height: 42px; min-width: 42px; padding: 0 8px; border: 0; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 2px; cursor: pointer; border-radius: 8px; font: inherit; font-weight: 700; font-size: 13px; }
.vp-btn:hover { background: rgba(255,255,255,.12); }
.vp-btn em { font-style: normal; font-size: 10px; font-weight: 800; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -42%); }
.vp-btn .ic-rewind, .vp-btn .ic-forward { width: 24px; height: 24px; }
.vp-time { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; opacity: .92; }
.vp-spacer { flex: 1; }
.when-playing, .when-muted, .when-fs { display: none !important; }
.vplayer.is-playing .when-paused { display: none !important; }
.vplayer.is-playing .when-playing { display: inline-flex !important; }
.vplayer.is-muted .when-sound { display: none !important; }
.vplayer.is-muted .when-muted { display: inline-flex !important; }
.vplayer.is-fs .when-normal { display: none !important; }
.vplayer.is-fs .when-fs { display: inline-flex !important; }
.vp-seek { position: relative; height: 22px; margin: 0 8px; display: flex; align-items: center; }
.vp-seek::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); }
.vp-seek-buf, .vp-seek-fill { position: absolute; left: 0; height: 4px; border-radius: 4px; pointer-events: none; width: 0; }
.vp-seek-buf { background: rgba(255,255,255,.4); }
.vp-seek-fill { background: var(--accent); }
.vp-seek input { position: relative; z-index: 2; width: 100%; height: 22px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; padding: 0; min-height: 0; border: 0; box-shadow: none; }
.vp-seek input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.vp-seek input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .5); }
.vp-seek input::-moz-range-track { height: 4px; background: transparent; }
.vp-seek input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
.vp-seek input:focus { box-shadow: none; }
.vp-speed { min-width: 46px; }
@media (max-width: 420px) { .vp-vol { display: none; } .vp-btn { min-width: 38px; padding: 0 6px; } .vp-time { font-size: 11.5px; padding: 0 4px; } .vp-bigplay { width: 66px; height: 66px; } }

/* Full screen (native or fallback for iPhone) */
.vplayer.is-fs { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: #000; border-radius: 0; }
.vplayer.is-fs .vp-stage { width: min(100vw, 177.78vh); width: min(100vw, 177.78dvh); }
.vplayer:fullscreen { width: 100%; height: 100%; }
body.vp-lock { overflow: hidden; }

/* PDF viewer */
.pdf-box { background: #EAE5F3; }
.pdf-bar { position: sticky; top: var(--topbar); z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.pdf-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pdf-pages { padding: 12px 8px; display: grid; gap: 10px; justify-items: center; max-height: 78vh; overflow: auto; -webkit-overflow-scrolling: touch; }
.pdf-pages canvas { width: 100%; max-width: 900px; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); border-radius: 4px; }
.pdf-loading { padding: 50px 0; color: var(--muted); display: flex; align-items: center; gap: 10px; }
@media (max-width: 480px) { .pdf-actions .btn span { display: none; } }
@media (min-width: 720px) { .pdf-bar { position: static; } }
