:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e5eaf1;
  --text: #172033;
  --muted: #6d778a;
  --primary: #3867f2;
  --primary-dark: #274bc1;
  --primary-soft: #edf2ff;
  --success: #168767;
  --success-soft: #eaf8f4;
  --warning: #b97117;
  --warning-soft: #fff5e8;
  --danger: #c94747;
  --danger-soft: #fff0f0;
  --sidebar: #17233d;
  --sidebar-muted: #9cabca;
  --shadow: 0 14px 42px rgba(28, 39, 60, .08);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-width: 248px;
  --topbar-height: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: linear-gradient(135deg, #f4f7fb 0%, #eef3ff 100%);
}
.login-brand {
  position: relative;
  overflow: hidden;
  padding: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  background: linear-gradient(145deg, #17233d 0%, #243a70 58%, #3867f2 100%);
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
  right: -190px;
  bottom: -180px;
  box-shadow: 0 0 0 70px rgba(255,255,255,.035), 0 0 0 150px rgba(255,255,255,.025);
}
.brand-mark { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.02em; font-size: 24px; position: relative; z-index: 1; }
.brand-logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: white; color: var(--primary); font-weight: 900; }
.login-hero { max-width: 640px; position: relative; z-index: 1; }
.login-hero h1 { font-size: clamp(38px, 5vw, 66px); line-height: .98; letter-spacing: -.05em; margin: 0 0 24px; }
.login-hero p { margin: 0; color: rgba(255,255,255,.76); font-size: 18px; line-height: 1.65; max-width: 580px; }
.login-badges { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.login-badge { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); padding: 9px 12px; border-radius: 999px; font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 34px; }
.login-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); }

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 700; color: #4b566c; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid #dbe1ea;
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 130px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: #9fb4ff; box-shadow: 0 0 0 4px rgba(56,103,242,.10); }

.btn { border: 0; border-radius: 11px; padding: 10px 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #eef2f7; color: #2f3a50; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-block { width: 100%; padding: 13px 16px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 11px; background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); color: white; padding: 22px 16px; display: flex; flex-direction: column; z-index: 20; }
.sidebar .brand-mark { padding: 4px 8px 24px; font-size: 20px; }
.sidebar .brand-logo { width: 36px; height: 36px; border-radius: 11px; }
.nav-label { color: #7182a7; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 800; padding: 12px 12px 8px; }
.nav { display: grid; gap: 5px; }
.nav-item { border: 0; background: transparent; color: var(--sidebar-muted); width: 100%; text-align: left; display: flex; align-items: center; gap: 11px; border-radius: 11px; padding: 11px 12px; font-weight: 650; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: rgba(255,255,255,.11); color: white; }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding: 16px 8px 4px; color: var(--sidebar-muted); font-size: 12px; }

.main { min-width: 0; }
.topbar { height: var(--topbar-height); background: rgba(255,255,255,.88); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 28px; position: sticky; top: 0; z-index: 15; }
.page-title { font-weight: 800; letter-spacing: -.02em; font-size: 19px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px 7px; border: 1px solid var(--line); background: white; border-radius: 13px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; }
.user-meta { line-height: 1.15; }
.user-name { font-size: 13px; font-weight: 800; }
.user-role { font-size: 11px; color: var(--muted); margin-top: 3px; }
.content { padding: 30px; max-width: 1440px; margin: 0 auto; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.hero h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.035em; }
.hero p { margin: 0; color: var(--muted); max-width: 760px; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 18px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 9px; }
.metric-value { font-size: 27px; font-weight: 850; letter-spacing: -.035em; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-12 { grid-column: span 12; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 5px 18px rgba(28,39,60,.035); overflow: hidden; }
.card-head { padding: 20px 22px 0; display: flex; gap: 12px; align-items: center; }
.card-title { font-size: 16px; font-weight: 850; letter-spacing: -.015em; }
.card-body { padding: 20px 22px 22px; }

.course-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.course-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 18px; min-height: 230px; transition: transform .18s ease, box-shadow .18s ease; }
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.course-card h3 { margin: 0 0 8px; font-size: 19px; letter-spacing: -.025em; }
.course-card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.course-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 800; background: var(--primary-soft); color: var(--primary); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.gray { background: #eef1f5; color: #697487; }
.course-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.progress-track { height: 7px; background: #edf0f5; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: inherit; transition: width .2s ease; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; font-weight: 800; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.search { min-width: 260px; max-width: 380px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(13,22,40,.46); display: grid; place-items: center; z-index: 100; padding: 24px; }
.modal { width: min(620px, 100%); max-height: 88vh; overflow-y: auto; background: white; border-radius: 22px; box-shadow: 0 30px 80px rgba(13,22,40,.24); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; }

.course-shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; }
.course-nav { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; height: fit-content; position: sticky; top: calc(var(--topbar-height) + 20px); }
.course-nav h3 { margin: 4px 8px 14px; font-size: 14px; }
.module-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; color: var(--muted); margin: 18px 8px 7px; }
.lesson-link { width: 100%; border: 0; background: transparent; border-radius: 10px; padding: 10px 9px; text-align: left; color: #536078; }
.lesson-link:hover, .lesson-link.active { background: var(--primary-soft); color: var(--primary); }
.lesson-title { font-size: 13px; font-weight: 700; }
.course-reader { min-width: 0; }
.reader-head { background: linear-gradient(135deg, #17233d, #3153a7); color: white; border-radius: 22px; padding: 28px; margin-bottom: 18px; }
.reader-head .eyebrow { color: #b8c8f2; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.reader-head h1 { margin: 8px 0 10px; font-size: 30px; letter-spacing: -.035em; }
.reader-head p { margin: 0; color: rgba(255,255,255,.72); }
.lesson-card { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.lesson-card h2 { margin: 0 0 22px; font-size: 25px; letter-spacing: -.025em; }
.content-block { margin: 18px 0; line-height: 1.7; }
.content-block h1, .content-block h2, .content-block h3, .content-block h4 { line-height: 1.2; margin: 28px 0 12px; }
.callout { border-left: 4px solid var(--primary); background: var(--primary-soft); padding: 15px 17px; border-radius: 0 12px 12px 0; }
.callout.warning { border-color: var(--warning); background: var(--warning-soft); }
.callout.success { border-color: var(--success); background: var(--success-soft); }
.callout-title { font-weight: 850; margin-bottom: 5px; }
.content-image { margin: 22px 0; text-align: center; }
.content-image img { max-width: 100%; border-radius: 14px; border: 1px solid var(--line); }
.content-image figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; }
.code-block { background: #101827; color: #dce5f5; padding: 18px; border-radius: 14px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre; }
.practice { border: 1px solid #cfe2ff; background: #f7faff; padding: 20px; border-radius: 16px; }
.practice h3 { margin-top: 0; }
.quiz { border: 1px solid #dfe4ef; padding: 20px; border-radius: 16px; background: #fbfcfe; }
.question { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.question:first-of-type { border-top: 0; padding-top: 0; }
.option { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin: 7px 0; background: white; }
.quiz-result { padding: 14px; border-radius: 12px; margin-top: 14px; font-weight: 750; }
.quiz-result.pass { background: var(--success-soft); color: var(--success); }
.quiz-result.fail { background: var(--danger-soft); color: var(--danger); }
.block-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.toast-stack { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 10px; z-index: 200; }
.toast { min-width: 280px; max-width: 430px; padding: 13px 15px; background: #172033; color: white; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #8e2e2e; }
.toast.success { background: #176a55; }

.mobile-menu { display: none; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-8, .col-7, .col-6, .col-5, .col-4 { grid-column: span 12; }
}

@media (max-width: 860px) {
  :root { --sidebar-width: 0px; }
  .shell { display: block; }
  .sidebar { display: none; position: fixed; width: 260px; left: 0; top: 0; }
  .sidebar.open { display: flex; }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 0 16px; gap: 10px; }
  .content { padding: 20px 16px; }
  .course-shell { grid-template-columns: 1fr; }
  .course-nav { position: static; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 20px; }
}

@media (max-width: 620px) {
  .metrics, .course-grid { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; flex-direction: column; }
  .user-meta { display: none; }
  .content { padding-top: 18px; }
  .lesson-card { padding: 19px; }
  .reader-head { padding: 22px; }
  .search { min-width: 100%; }
}

/* Импорт JSON: отдельная проверка, предпросмотр и подтверждение. */
.modal-wide { width: min(820px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.import-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.import-dropzone { border: 1.5px dashed #b9c5da; border-radius: 16px; background: #f8faff; min-height: 126px; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: left; outline: none; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.import-dropzone:hover, .import-dropzone:focus, .import-dropzone.dragging { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 4px rgba(56,103,242,.08); }
.import-drop-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; background: var(--primary); color: white; font-size: 12px; font-weight: 900; letter-spacing: .05em; }
.import-file-meta { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.import-status { margin-top: 14px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); font-size: 13px; font-weight: 750; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(56,103,242,.25); border-top-color: var(--primary); animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.import-errors { margin-top: 14px; padding: 16px; border: 1px solid #efc5c5; border-radius: 14px; background: var(--danger-soft); color: #762d2d; }
.import-errors .import-panel-title { font-weight: 850; margin-bottom: 8px; color: var(--danger); }
.import-errors p { margin: 0 0 12px; }
.import-errors ol { margin: 8px 0 14px; padding-left: 22px; display: grid; gap: 10px; }
.import-errors li { padding-left: 3px; }
.import-errors code { display: inline-block; margin-bottom: 3px; color: #643030; font-size: 12px; overflow-wrap: anywhere; }
.btn-small { padding: 7px 10px; font-size: 12px; }
.import-preview { margin-top: 16px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.import-valid { display: flex; gap: 10px; align-items: center; padding: 13px 16px; background: var(--success-soft); color: var(--success); }
.import-valid > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: white; font-weight: 900; }
.import-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px; }
.import-preview-head .eyebrow { color: var(--primary); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.import-preview-head h3 { margin: 5px 0 4px; font-size: 20px; }
.import-meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.import-meta-grid > div { padding: 13px 16px; border-right: 1px solid var(--line); min-width: 0; }
.import-meta-grid > div:last-child { border-right: 0; }
.import-meta-grid span, .import-stat-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.import-meta-grid strong { font-size: 13px; overflow-wrap: anywhere; }
.import-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); padding: 14px 10px; background: var(--surface-soft); }
.import-stat-grid > div { text-align: center; padding: 4px; }
.import-stat-grid strong { display: block; font-size: 19px; margin-bottom: 2px; }
.import-warning-list { padding: 14px 16px; display: grid; gap: 7px; border-top: 1px solid var(--line); background: var(--warning-soft); color: #765020; font-size: 12px; }
.import-warning { padding: 11px 13px; border-radius: 11px; background: var(--warning-soft); color: #765020; font-size: 12px; }
.import-conflict { margin: 16px; padding: 14px; border: 1px solid #efcc9d; border-radius: 13px; background: var(--warning-soft); color: #65461f; }
.import-conflict > strong { display: block; margin-bottom: 5px; }
.confirm-check { display: flex; align-items: flex-start; gap: 9px; margin-top: 12px; font-size: 12px; line-height: 1.45; font-weight: 650; cursor: pointer; }
.confirm-check input { margin-top: 2px; }
.import-success { padding: 30px 12px 18px; text-align: center; }
.import-success-icon { width: 62px; height: 62px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 30px; font-weight: 900; }
.import-success h3 { margin: 0 0 8px; font-size: 24px; }
.import-success p { max-width: 560px; margin: 0 auto 20px; color: var(--muted); line-height: 1.55; }

@media (max-width: 700px) {
  .import-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-meta-grid > div:nth-child(2) { border-right: 0; }
  .import-meta-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .import-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 0; }
  .import-preview-head { flex-direction: column; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* Отдельное окно курса: без основной колонки «Рабочее пространство». */
.course-window { min-height: 100vh; background: var(--bg); }
.course-window-topbar { height: 68px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 28px; background: rgba(255,255,255,.94); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.course-window-topbar .brand-mark { color: var(--text); font-size: 19px; }
.course-window-topbar .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
.standalone-course-content { width: min(1600px, 100%); margin: 0 auto; padding: 24px 28px 40px; }
.standalone-course-content .course-nav { top: 92px; }

@media (max-width: 860px) {
  .course-window-topbar { padding: 0 16px; }
  .course-window-topbar .user-meta { display: none; }
  .standalone-course-content { padding: 16px; }
}

/* Learning UX v0.2 */
.continue-learning { display:flex; align-items:center; justify-content:space-between; gap:24px; background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:24px; margin-bottom:24px; box-shadow:0 10px 28px rgba(20,35,70,.05); }
.continue-copy { min-width:0; flex:1; }
.continue-copy h2 { margin:6px 0 8px; font-size:24px; letter-spacing:-.03em; }
.continue-copy p { margin:0 0 14px; color:var(--muted); }
.continue-progress-row { display:grid; grid-template-columns:minmax(0,420px) auto; align-items:center; gap:12px; margin-bottom:7px; }
.course-progress-line { display:grid; grid-template-columns:1fr auto; align-items:center; gap:10px; }
.course-module { border-top:1px solid var(--line); padding-top:8px; margin-top:8px; }
.course-module summary { cursor:pointer; list-style:none; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:9px 8px; color:var(--text); font-size:12px; font-weight:800; }
.course-module summary::-webkit-details-marker { display:none; }
.course-module-chevron { width:16px; height:16px; display:grid; place-items:center; color:var(--muted); transform:rotate(0deg); transition:transform .16s ease; flex:0 0 auto; }
.course-module-chevron .ui-icon { width:13px; height:13px; }
.course-module[open] .course-module-chevron { transform:rotate(90deg); }
.course-module summary > span:nth-of-type(2) { flex:1; }
.module-lessons { padding-bottom:5px; }
.lesson-link { display:grid; grid-template-columns:22px minmax(0,1fr); align-items:start; gap:5px; }
.lesson-link:disabled { opacity:.52; cursor:not-allowed; }
.lesson-link.completed { color:#3a6957; }
.lesson-state { text-align:center; font-size:12px; line-height:1.5; font-weight:800; }
.compact-reader-head h1 { margin-bottom:8px; }
.lesson-footer-nav { margin-top:18px; background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:16px; display:flex; justify-content:space-between; align-items:center; gap:16px; }
.lesson-complete-side { display:flex; align-items:center; gap:12px; justify-content:flex-end; }
.success-text { color:#2c7659; font-weight:700; }
.course-complete-banner { margin-bottom:20px; display:flex; align-items:center; justify-content:space-between; gap:20px; padding:22px 24px; border:1px solid #bfe3d3; background:#f1fbf6; border-radius:18px; }
.course-complete-banner h2 { margin:5px 0 6px; }
.course-complete-banner p { margin:0; color:var(--muted); }
.quiz-feedback { margin-top:12px; display:grid; gap:8px; }
.quiz-feedback-item { border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:var(--surface); }
.quiz-feedback-item.correct { border-color:#c9e6d8; background:#f6fcf9; }
.quiz-feedback-item.incorrect { border-color:#f0d0d0; background:#fff8f8; }
.quiz-feedback-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:6px; }
.access-list { display:grid; gap:10px; }
.access-item { display:grid; grid-template-columns:20px minmax(0,1fr); gap:10px; align-items:start; border:1px solid var(--line); border-radius:12px; padding:12px 14px; cursor:pointer; }
.access-item:hover { background:#fafbfe; }
.access-item span { display:grid; gap:3px; }
.access-item small { color:var(--muted); }

@media (max-width: 760px) {
  .continue-learning, .course-complete-banner, .lesson-footer-nav { align-items:flex-start; flex-direction:column; }
  .continue-progress-row { grid-template-columns:1fr auto; }
  .lesson-complete-side { width:100%; justify-content:space-between; }
}

/* --------------------------------------------------------------------------
   Responsive learning surface + Snappify-inspired code presentation (v0.2.2)
   -------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, video, svg { max-width: 100%; }

/* Keep long-form learning content readable while still using widescreen space. */
.content {
  width: 100%;
  max-width: 1680px;
  padding-inline: clamp(18px, 2.2vw, 40px);
}
.standalone-course-content {
  width: min(1540px, 100%);
  padding-inline: clamp(16px, 2.4vw, 38px);
}
.course-shell {
  grid-template-columns: clamp(268px, 19vw, 320px) minmax(0, 1040px);
  justify-content: center;
  align-items: start;
  gap: clamp(18px, 2vw, 30px);
}
.course-reader { width: 100%; max-width: 1040px; }
.reader-head { padding: clamp(22px, 2.3vw, 34px); }
.reader-head h1 { font-size: clamp(26px, 2.15vw, 34px); }
.lesson-card { padding: clamp(20px, 2.25vw, 34px); }
.lesson-card h2 { font-size: clamp(22px, 1.8vw, 28px); }
.content-block { font-size: clamp(15px, .15vw + 14.5px, 17px); }

/* Images stay visible as learning illustrations, not full-screen posters. */
.content-image {
  margin: clamp(20px, 2.2vw, 30px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  --adaptive-image-max-height: clamp(300px, 62svh, 680px);
}
.content-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(var(--image-max-height, 10000px), var(--adaptive-image-max-height));
  object-fit: contain;
  object-position: center;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(22, 32, 51, .08);
}
.content-image figcaption {
  width: min(760px, 100%);
  margin-top: 10px;
  line-height: 1.45;
}
.content-block video {
  display: block;
  width: 100%;
  max-height: min(68svh, 720px);
  object-fit: contain;
  background: #0d1320;
}

/* Snappify / Cool Snippets-inspired visual treatment for code. */
.code-snippet {
  margin: clamp(24px, 3vw, 38px) 0;
  max-width: 100%;
}
.code-snippet-stage {
  position: relative;
  overflow: hidden;
  padding: clamp(16px, 2.7vw, 34px);
  border-radius: 22px;
  background:
    radial-gradient(circle at 12% 12%, rgba(255,255,255,.22), transparent 26%),
    radial-gradient(circle at 88% 80%, rgba(119,92,246,.24), transparent 28%),
    linear-gradient(135deg, #7357ef 0%, #536df0 43%, #3778d9 100%);
  box-shadow: 0 20px 48px rgba(48, 67, 136, .18);
}
.code-snippet-stage::before,
.code-snippet-stage::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}
.code-snippet-stage::before {
  width: 150px;
  height: 150px;
  left: -55px;
  bottom: -70px;
  background: rgba(255,255,255,.10);
}
.code-snippet-stage::after {
  width: 180px;
  height: 180px;
  right: -75px;
  top: -85px;
  border: 1px solid rgba(255,255,255,.20);
}
.code-window {
  position: relative;
  z-index: 1;
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 16px;
  background: #111827;
  box-shadow: 0 22px 48px rgba(8, 14, 30, .34);
}
.code-window-bar {
  min-height: 46px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(27, 36, 54, .96);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.code-window-controls { display: flex; align-items: center; gap: 7px; }
.code-window-controls span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.code-window-controls span:nth-child(1) { background: #ff5f57; }
.code-window-controls span:nth-child(2) { background: #febc2e; }
.code-window-controls span:nth-child(3) { background: #28c840; }
.code-window-language {
  min-width: 0;
  color: #aebbd0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.code-copy {
  justify-self: end;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.055);
  color: #cbd5e1;
  border-radius: 9px;
  min-height: 30px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 750;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.code-copy:hover { background: rgba(255,255,255,.10); color: white; }
.code-copy.copied { color: #86efac; border-color: rgba(134,239,172,.28); }
.code-copy-icon { font-size: 13px; line-height: 1; }
.code-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
  background: #111827;
}
.code-line-numbers {
  user-select: none;
  min-width: 46px;
  padding: 20px 12px 20px 10px;
  color: #526077;
  background: rgba(7, 12, 23, .22);
  border-right: 1px solid rgba(255,255,255,.055);
  text-align: right;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.7;
}
.code-line-numbers span { display: block; height: 1.7em; }
.code-snippet-pre {
  min-width: 0;
  margin: 0;
  padding: 20px clamp(18px, 2vw, 28px);
  overflow: auto;
  color: #e5e7eb;
  background: transparent;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(12.5px, .18vw + 12px, 14px);
  line-height: 1.7;
  tab-size: 4;
  white-space: pre;
  scrollbar-color: #475569 #111827;
}
.code-snippet-pre code { font: inherit; color: inherit; }
.code-caption {
  margin: 9px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}
.token-comment { color: #6f7f98; font-style: italic; }
.token-string { color: #a6e3a1; }
.token-property { color: #89b4fa; }
.token-keyword { color: #cba6f7; font-weight: 650; }
.token-number { color: #fab387; }
.token-literal { color: #f38ba8; font-weight: 650; }

/* Large desktops and ultrawide screens: use space without stretching reading lines. */
@media (min-width: 1560px) {
  .content { max-width: 1760px; }
  .course-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .standalone-course-content { width: min(1640px, 100%); }
  .course-shell { grid-template-columns: 320px minmax(0, 1080px); gap: 34px; }
  .course-reader { max-width: 1080px; }
  .content-image { --adaptive-image-max-height: min(64svh, 720px); }
}

/* Laptop / landscape tablet. */
@media (max-width: 1180px) {
  .content { padding-inline: 22px; }
  .course-shell { grid-template-columns: 260px minmax(0, 1fr); gap: 18px; }
  .course-reader { max-width: none; }
  .course-nav { padding: 14px; }
}

/* Tablets: reader gets full width and course navigation moves above content. */
@media (max-width: 1024px) {
  .course-shell { grid-template-columns: minmax(0, 1fr); }
  .course-nav {
    position: static;
    width: 100%;
    max-height: none;
  }
  .standalone-course-content .course-nav { top: auto; }
  .content-image { --adaptive-image-max-height: min(56svh, 560px); }
  .code-snippet-stage { border-radius: 18px; }
}

/* Small tablets and phones. */
@media (max-width: 760px) {
  :root { --topbar-height: 66px; }
  .topbar { min-height: var(--topbar-height); height: auto; }
  .page-title { font-size: 16px; }
  .content { padding: 16px 14px 28px; }
  .standalone-course-content { padding: 14px 12px 30px; }
  .course-window-topbar { min-height: 62px; height: auto; padding: 10px 12px; }
  .course-window-topbar .brand-mark { font-size: 16px; }
  .course-window-topbar .brand-logo { width: 32px; height: 32px; }
  .reader-head, .lesson-card { border-radius: 16px; }
  .reader-head { padding: 20px 18px; }
  .reader-head h1 { font-size: 24px; }
  .lesson-card { padding: 18px 16px; }
  .lesson-card h2 { font-size: 22px; margin-bottom: 18px; }
  .content-block { line-height: 1.65; }
  .content-image { --adaptive-image-max-height: min(50svh, 430px); }
  .content-image img {
    border-radius: 12px;
  }
  .code-snippet { margin: 22px -2px; }
  .code-snippet-stage { padding: 10px; border-radius: 15px; }
  .code-window { border-radius: 12px; }
  .code-window-bar { min-height: 42px; padding: 0 10px; }
  .code-line-numbers { min-width: 38px; padding: 16px 9px 16px 6px; font-size: 12px; }
  .code-snippet-pre { padding: 16px 14px; font-size: 12.5px; }
  .code-copy { padding: 5px 7px; }
  .code-copy-label { display: none; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  .modal-backdrop { padding: 10px; }
  .modal { border-radius: 16px; max-height: 94svh; }
  .modal-head, .modal-body { padding: 16px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; max-width: none; }
}

@media (max-width: 520px) {
  .metrics { gap: 10px; }
  .metric { padding: 14px; }
  .metric-value { font-size: 23px; }
  .hero h1 { font-size: 27px; }
  .course-card { padding: 16px; min-height: 0; }
  .course-topline { flex-direction: column; }
  .btn { min-height: 42px; }
  .lesson-footer-nav .btn,
  .lesson-complete-side,
  .lesson-complete-side .btn { width: 100%; }
  .lesson-complete-side { display: grid; }
  .content-image { --adaptive-image-max-height: min(46svh, 380px); }
  .code-window-language { text-align: left; }
  .code-window-controls { display: none; }
  .code-window-bar { grid-template-columns: minmax(0,1fr) auto; }
  .code-line-numbers { display: none; }
  .code-editor { grid-template-columns: minmax(0, 1fr); }
  .code-snippet-pre { line-height: 1.65; }
}

@media (max-width: 380px) {
  .content { padding-inline: 10px; }
  .standalone-course-content { padding-inline: 8px; }
  .lesson-card { padding: 16px 13px; }
  .content-image { --adaptive-image-max-height: 42svh; }
  .code-snippet-stage { padding: 7px; }
}

/* Rich learning content: v1.1 formatting contract. */
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content p { margin: 0 0 14px; }
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 { margin: 26px 0 12px; line-height: 1.25; }
.markdown-lead { font-size: clamp(17px, .25vw + 16px, 20px); line-height: 1.75; color: #334155; }
.markdown-compact p { margin-bottom: 8px; }
.text-lead { font-size: clamp(17px, .25vw + 16px, 20px); color: #334155; }
.text-small { font-size: 13px; }
.text-muted { color: var(--muted); }
.inline-code {
  display: inline;
  padding: .16em .42em .18em;
  border: 1px solid #cdd8ff;
  border-radius: 7px;
  background: linear-gradient(180deg, #f4f6ff 0%, #edf1ff 100%);
  color: #4054b8;
  box-shadow: inset 0 -1px 0 rgba(64, 84, 184, .08), 0 1px 2px rgba(30, 41, 59, .05);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.question .inline-code,
.option .inline-code {
  background: linear-gradient(180deg, #eef2ff 0%, #e8edff 100%);
  border-color: #c4cffd;
  color: #3448a5;
}
mark {
  padding: .05em .18em;
  border-radius: 4px;
  background: #fff0a6;
  color: inherit;
}
del { color: #64748b; }
.markdown-content a,
.content-block > a { color: var(--primary); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.markdown-content a:hover,
.content-block > a:hover { text-decoration-thickness: 2px; }

.markdown-list,
.structured-list > ul,
.structured-list > ol { margin: 12px 0 18px; padding-left: 1.55rem; }
.markdown-list li,
.structured-list > ul > li,
.structured-list > ol > li { margin: 7px 0; padding-left: .2rem; }
.structured-list h4 { margin: 0 0 10px; }
.structured-list.checklist > ul,
ul.markdown-checklist { list-style: none; padding-left: 0; }
.structured-list.checklist > ul > li,
ul.markdown-checklist > li { display: flex; align-items: flex-start; gap: 10px; padding-left: 0; }
.check-marker {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #b6c2d2;
  border-radius: 6px;
  background: white;
  color: white;
  font-size: 12px;
  font-weight: 900;
}
.check-marker.checked { border-color: var(--success); background: var(--success); }
.nested-list { margin: 8px 0 2px; padding-left: 1.3rem; }
.nested-list li { margin: 5px 0; }

.markdown-quote,
.content-quote blockquote {
  margin: 18px 0;
  padding: 16px 20px;
  border-left: 4px solid #8195ff;
  border-radius: 0 14px 14px 0;
  background: #f6f7ff;
  color: #344054;
  font-size: clamp(16px, .2vw + 15px, 18px);
  line-height: 1.7;
}
.content-quote { margin: 24px 0; }
.content-quote blockquote { margin-bottom: 8px; }
.content-quote blockquote p { margin: 0 0 10px; }
.content-quote blockquote p:last-child { margin-bottom: 0; }
.content-quote figcaption { padding-left: 24px; color: var(--muted); font-size: 13px; }

.divider-wrap { position: relative; margin: 30px 0; text-align: center; }
.divider-wrap > span {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 0 12px;
  background: var(--surface, #fff);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.content-divider { margin: 0; border: 0; border-top: 1px solid var(--line); }
.divider-wrap > span + .content-divider { position: absolute; top: 50%; left: 0; right: 0; }
.content-divider.dashed { border-top-style: dashed; }
.content-divider.dots { border-top: 0; height: 8px; background: radial-gradient(circle, #a8b4c4 1.5px, transparent 1.6px) center / 12px 8px repeat-x; }
.content-divider.space { visibility: hidden; height: 18px; }

.callout.tip { border-color: #06a77d; background: #ecfdf7; }
.callout.danger { border-color: #e24a4a; background: #fff1f1; }
.callout.note { border-color: #8b78d7; background: #f7f4ff; }
.callout.example { border-color: #6d82e8; background: #f2f5ff; }
.callout .markdown-content p { margin-bottom: 9px; }
.callout .markdown-content p:last-child { margin-bottom: 0; }

.formatted-table { margin: 24px 0; border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.formatted-table table { margin: 0; width: 100%; border-collapse: collapse; }
.formatted-table th { background: #f6f8fb; font-weight: 800; }
.formatted-table th,
.formatted-table td { padding: 13px 15px; vertical-align: top; border-bottom: 1px solid var(--line); }
.formatted-table tbody tr:last-child td { border-bottom: 0; }
.formatted-table.striped tbody tr:nth-child(even) { background: #fafbfd; }
.formatted-table.compact th,
.formatted-table.compact td { padding: 9px 12px; }
.table-caption { padding: 9px 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.image-title { width: min(760px, 100%); margin-bottom: 10px; font-weight: 800; text-align: left; }
.image-credit { width: min(760px, 100%); margin-top: 5px; color: var(--muted); font-size: 11px; text-align: center; }
.content-image.align-left { align-items: flex-start; }
.content-image.align-right { align-items: flex-end; }
.content-image.thumbnail img { max-width: min(360px, 100%); max-height: min(var(--image-max-height, 10000px), var(--adaptive-image-max-height), 320px); }
.content-image.full_width img { width: 100%; }

.code-title { margin: 0 4px 10px; font-size: 14px; font-weight: 800; color: #334155; }
.code-editor.without-line-numbers { grid-template-columns: minmax(0, 1fr); }
.code-source-line { display: block; min-height: 1.7em; padding: 0 7px; margin: 0 -7px; border-radius: 3px; }
.code-source-line.is-highlighted { background: rgba(250, 204, 21, .10); box-shadow: inset 3px 0 0 rgba(250, 204, 21, .75); }
.code-line-numbers span.is-highlighted { color: #facc15; background: rgba(250, 204, 21, .08); }
.code-wrap .code-snippet-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .markdown-quote,
  .content-quote blockquote { padding: 14px 15px; }
  .content-quote figcaption { padding-left: 18px; }
  .formatted-table { border-radius: 11px; }
  .formatted-table table { min-width: 560px; }
  .structured-list > ul,
  .structured-list > ol,
  .markdown-list { padding-left: 1.25rem; }
}

/* v0.3.0: learning outcomes, completed practice, downloads and compact course reports. */
.learning-outcomes {
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid #dce5f1;
  border-radius: 14px;
  background: #f8faff;
}
.learning-outcomes > strong { display: block; margin-bottom: 8px; color: #26354d; }
.learning-outcomes ul { margin: 0; padding-left: 1.2rem; }
.learning-outcomes li { margin: 5px 0; color: #475569; }

.practice { border: 1px solid #dce6f3; border-left: 4px solid #6d82e8; border-radius: 14px; padding: 18px; background: #fbfcff; }
.practice h3 { margin-top: 12px; }
.practice-actions, .practice-answer { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.practice-answer { display: grid; align-items: stretch; }
.practice-answer label { font-weight: 750; color: #334155; }
.practice-answer textarea { width: 100%; min-height: 108px; resize: vertical; }
.practice-solution { margin-top: 16px; padding: 15px 17px; border-radius: 12px; border: 1px solid #bde8d8; background: #f0fbf7; }
.practice-solution h4 { margin: 0 0 8px; }
.practice-result { margin-top: 12px; padding: 11px 13px; border-radius: 10px; font-size: 14px; font-weight: 650; }
.practice-result.success { background: #ecfdf5; color: #08795b; border: 1px solid #b7ead8; }
.practice-result.error { background: #fff7ed; color: #9a4a0a; border: 1px solid #fed7aa; }

.download-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
  padding: 16px;
  border: 1px solid #dbe4f0;
  border-radius: 14px;
  background: #f9fbfe;
}
.download-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #edf2ff; color: var(--primary); font-size: 22px; font-weight: 900; }
.download-copy { min-width: 0; }
.download-copy > strong { display: block; color: #26354d; }
.download-copy p { margin: 5px 0; color: #64748b; }
.download-caption { margin-top: 4px; }

.progress-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.progress-summary-grid > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.progress-summary-grid span { display: block; color: var(--muted); font-size: 12px; }
.progress-summary-grid strong { display: block; margin-top: 4px; font-size: 22px; }
.admin-progress-cell { display: grid; grid-template-columns: minmax(90px,1fr) auto; align-items: center; gap: 9px; min-width: 160px; }

.course-mobile-toc { display: none; width: 100%; border: 1px solid #dbe4f0; background: #fff; color: #334155; border-radius: 12px; min-height: 46px; padding: 0 14px; align-items: center; justify-content: space-between; font: inherit; cursor: pointer; margin-bottom: 10px; }
.course-drawer-backdrop { display: none; }
body.drawer-open { overflow: hidden; }

@media (max-width: 760px) {
  .course-nav { display: none; }
  .course-mobile-toc { display: flex; }
  .course-drawer-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.42); opacity: 0; pointer-events: none; display: block; transition: opacity .18s ease; }
  .course-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
  .course-drawer { position: absolute; top: 0; left: 0; bottom: 0; width: min(88vw, 360px); overflow-y: auto; padding: 18px 14px 24px; background: #fff; box-shadow: 18px 0 50px rgba(15,23,42,.18); transform: translateX(-102%); transition: transform .2s ease; }
  .course-drawer-backdrop.open .course-drawer { transform: translateX(0); }
  .course-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
  .course-drawer .course-module { margin-bottom: 8px; }
  .download-block { grid-template-columns: auto minmax(0,1fr); }
  .download-block .btn { grid-column: 1 / -1; width: 100%; }
  .progress-summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 480px) {
  .progress-summary-grid { grid-template-columns: 1fr 1fr; }
  .practice { padding: 15px 13px; }
  .learning-outcomes { padding: 13px 14px; }
}

/* v0.4.0: certificates and unpublished-course access guard. */
.access-item.disabled { opacity: .58; cursor: not-allowed; background: #f7f8fb; }
.access-item.disabled input { cursor: not-allowed; }

.certificate-toolbar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.certificate-toolbar .input { width: min(460px, 100%); }
.certificate-grid { display: grid; gap: 16px; }
.certificate-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid #dce4f0;
  border-radius: 18px;
  background:
    radial-gradient(circle at 95% 0%, rgba(92,111,226,.12), transparent 25%),
    #fff;
  box-shadow: 0 10px 28px rgba(32,48,76,.06);
}
.certificate-card-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg,#4057d6,#7b61df);
  box-shadow: 0 10px 24px rgba(64,87,214,.22);
}
.certificate-card-copy { min-width: 0; }
.certificate-card-copy h3 { margin: 5px 0 6px; }
.certificate-link-preview {
  margin-top: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f6f8fc;
  border: 1px solid #e4e9f2;
  color: #64748b;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.certificate-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.certificate-table-link { display: flex; align-items: center; gap: 8px; min-width: 280px; }
.certificate-table-link a { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 820px) {
  .certificate-card { grid-template-columns: auto minmax(0, 1fr); }
  .certificate-card-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .certificate-card { grid-template-columns: 1fr; padding: 18px 15px; }
  .certificate-card-mark { width: 48px; height: 48px; }
  .certificate-card-actions { grid-column: auto; display: grid; grid-template-columns: 1fr; }
  .certificate-card-actions .btn { width: 100%; }
  .certificate-table-link { min-width: 220px; }
}

/* --------------------------------------------------------------------------
   UX polish v0.5.0
   -------------------------------------------------------------------------- */
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Consistent keyboard focus across interactive surfaces. */
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgba(56, 103, 242, .32);
  outline-offset: 2px;
}
.nav-label { color: #a7b6d4; }

/* Keep prose readable without shrinking diagrams, tables or code. */
.lesson-card > .text-body,
.lesson-card > .text-lead,
.lesson-card > .text-small,
.lesson-card > .text-muted,
.lesson-card > .markdown-content,
.lesson-card > .structured-list,
.lesson-card > .content-quote,
.lesson-card > .callout {
  width: min(780px, 100%);
  margin-left: auto;
  margin-right: auto;
}
.reader-head > p,
.reader-head > .learning-outcomes {
  max-width: 780px;
}

/* Broken images remain visible as a meaningful learning-state instead of vanishing. */
.image-fallback {
  width: min(760px, 100%);
  min-height: 150px;
  padding: 24px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  text-align: center;
  border: 1px dashed #bdc8d8;
  border-radius: 14px;
  background: #f8fafc;
  color: #667085;
}
.image-fallback strong { color: #344054; }
.image-fallback-path {
  margin-top: 5px;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 7px;
  background: #eef2f7;
  color: #667085;
  font: 11px/1.4 "Cascadia Code", Consolas, monospace;
  overflow-wrap: anywhere;
}

/* Quiz validation and answer review. */
.question-number { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.question-instruction {
  margin: 8px 0 10px;
  color: #59657a;
  font-size: 13px;
  font-weight: 700;
}
.question-missing {
  margin-inline: -10px;
  padding-inline: 10px;
  border-radius: 12px;
  background: #fff7f7;
  box-shadow: inset 3px 0 0 #d45454;
}
.quiz-validation {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #efc5c5;
  border-radius: 11px;
  background: var(--danger-soft);
  color: #7b3030;
}
.quiz-answer-review {
  display: grid;
  gap: 3px;
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(255,255,255,.66);
}
.quiz-answer-review > span,
.quiz-feedback-explanation > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.quiz-answer-review.correct-answer { background: #edf9f3; }
.quiz-feedback-explanation { margin-top: 10px; }
.quiz-feedback-explanation > .content-block { margin-top: 5px; }

/* Main navigation uses the same mobile drawer interaction as course contents. */
.sidebar-backdrop {
  display: none;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, .44);
}

/* Compact administrative actions. */
.course-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu-trigger { min-width: 42px; padding-inline: 12px; font-size: 18px; line-height: 1; }
.action-menu-popover {
  position: absolute;
  z-index: 60;
  right: 0;
  top: calc(100% + 7px);
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(22,32,51,.15);
}
.action-menu-popover button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 11px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.action-menu-popover button:hover { background: #f4f6fa; }
.action-menu-popover button.danger { color: var(--danger); }
.admin-course-table-wrap { overflow: visible; }

/* Recoverable page-level errors. */
.load-error {
  min-height: 320px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 28px;
  border: 1px solid #e5eaf1;
  border-radius: 18px;
  background: #fff;
}
.load-error-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 24px;
  font-weight: 900;
}
.load-error h2 { margin: 0 0 6px; }
.load-error p { margin: 0; color: var(--muted); }
.course-complete-actions { justify-content: flex-end; }

.user-toolbar { justify-content: flex-end; }
.user-toolbar .search { width: min(400px, 100%); }

@media (max-width: 860px) {
  .sidebar {
    display: flex;
    width: min(82vw, 280px);
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 18px 0 50px rgba(15,23,42,.20);
  }
  .sidebar.open { display: flex; transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    opacity: 0;
    pointer-events: none;
    display: block;
    transition: opacity .18s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
}

@media (max-width: 760px) {
  :where(.btn, .btn-icon, .nav-item, .lesson-link, .course-mobile-toc) { min-height: 44px; }
  .btn-icon { min-width: 44px; width: 44px; height: 44px; }
  .load-error { grid-template-columns: 1fr; min-height: 0; padding: 22px 18px; }
  .load-error .btn { width: 100%; }
  .course-complete-actions { width: 100%; justify-content: stretch; }
  .course-complete-actions .btn { flex: 1 1 180px; }
  .admin-course-table-wrap { overflow-x: auto; overflow-y: visible; }
  .action-menu-popover { position: static; margin-top: 6px; box-shadow: none; }
}

@media (max-width: 520px) {
  .user-toolbar .search { width: 100%; }
  .quiz-answer-review { padding: 9px; }
}

.metrics.metrics-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .metrics.metrics-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .metrics.metrics-4 { grid-template-columns: 1fr; }
}

/* Student administration: fast credential issuing without exposing stored passwords. */
.student-create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .9fr);
  gap: 22px;
}
.student-create-section {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfe;
}
.credential-generator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}
.password-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.access-list.compact { max-height: 310px; overflow-y: auto; padding-right: 4px; }
.credential-success { text-align: center; }
.credential-success h3 { margin: 10px 0 6px; }
.credential-card {
  margin: 20px auto;
  max-width: 620px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
.credential-person {
  padding: 15px 17px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}
.credential-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
}
.credential-row > span { color: var(--muted); font-size: 13px; font-weight: 700; }
.credential-row code,
.admin-login-code {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  background: #f5f7fa;
  color: #23324a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.credential-course-count { padding: 12px 17px; color: var(--muted); font-size: 13px; }
.credential-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }

@media (max-width: 760px) {
  .student-create-grid { grid-template-columns: 1fr; }
  .student-create-section { padding: 14px; }
  .password-input-row { grid-template-columns: 1fr; }
  .credential-row { grid-template-columns: 1fr; gap: 7px; }
  .credential-row .btn { width: 100%; }
  .credential-actions { flex-direction: column; }
  .credential-actions .btn { width: 100%; }
}

/* v0.6.0: language-learning audio block. */
.audio-block {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid #dbe4f0;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f7f9fd 100%);
  box-shadow: 0 8px 24px rgba(32, 48, 76, .05);
}
.audio-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin-bottom: 14px;
}
.audio-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #edf2ff;
  color: var(--primary);
  font-size: 23px;
  font-weight: 900;
}
.audio-copy { min-width: 0; }
.audio-copy > strong { display: block; color: #26354d; font-size: 17px; }
.audio-copy p { margin: 5px 0 6px; color: #64748b; }
.audio-player {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
}
.audio-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.audio-rate-label {
  display: grid;
  grid-template-columns: auto minmax(92px, 118px);
  gap: 9px;
  align-items: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}
.audio-rate { min-height: 40px; padding-top: 7px; padding-bottom: 7px; }
.audio-transcript {
  margin-top: 15px;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}
.audio-transcript summary {
  cursor: pointer;
  color: #334155;
  font-weight: 750;
  user-select: none;
}
.audio-transcript .markdown-content {
  margin-top: 10px;
  padding: 13px 15px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5eaf2;
}
.audio-caption { margin-top: 11px; line-height: 1.5; }

@media (max-width: 520px) {
  .audio-block { padding: 15px 13px; }
  .audio-tools { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .audio-rate-label { grid-template-columns: auto 1fr; }
  .audio-tools .btn { width: 100%; }
}

/* v0.7.0: server-backed educational video player. */
.video-block {
  margin: 26px 0;
  padding: 18px;
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfdff 0%, #f7f9fd 100%);
  box-shadow: 0 10px 28px rgba(32, 48, 76, .06);
  --adaptive-video-max-height: min(68svh, 720px);
}
.video-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin-bottom: 14px;
}
.video-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #edf2ff;
  color: var(--primary);
  font-size: 17px;
  font-weight: 900;
}
.video-copy { min-width: 0; }
.video-copy > strong { display: block; color: #26354d; font-size: 17px; }
.video-copy p { margin: 5px 0 6px; color: #64748b; }
.video-frame {
  width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 15px;
  background: #0b1220;
  border: 1px solid rgba(15, 23, 42, .16);
}
.video-block .video-player {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(var(--video-max-height, 10000px), var(--adaptive-video-max-height));
  object-fit: contain;
  background: #0b1220;
}
.video-tools {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.video-rate-label {
  display: grid;
  grid-template-columns: auto minmax(92px, 118px);
  gap: 9px;
  align-items: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}
.video-rate { min-height: 40px; padding-top: 7px; padding-bottom: 7px; }
.video-caption { margin-top: 11px; line-height: 1.5; }

@media (min-width: 1560px) {
  .video-block { --adaptive-video-max-height: min(72svh, 780px); }
}
@media (max-width: 1024px) {
  .video-block { --adaptive-video-max-height: min(62svh, 620px); }
}
@media (max-width: 760px) {
  .video-block { --adaptive-video-max-height: min(56svh, 500px); padding: 15px 13px; }
  .video-frame { border-radius: 12px; }
}
@media (max-width: 520px) {
  .video-block { --adaptive-video-max-height: min(48svh, 380px); }
  .video-tools { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .video-rate-label { grid-template-columns: auto 1fr; }
  .video-tools .btn { width: 100%; }
}

/* v0.9.0 — Course Player v2 / JSON v1.6 */
.lesson-top-anchor { scroll-margin-top: 130px; }
.lesson-section-nav {
  position: sticky;
  top: 82px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
  padding: 10px 12px;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(15,23,42,.05);
  backdrop-filter: blur(10px);
}
.lesson-section-nav-label { flex: 0 0 auto; font-size: 12px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lesson-section-nav-links { display: flex; gap: 7px; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.lesson-section-nav a {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.lesson-section-nav a:hover, .lesson-section-nav a.active { background: #eef5f0; color: var(--primary); }

.lesson-section {
  scroll-margin-top: 150px;
  margin: 0 0 34px;
  padding: 0 0 30px;
  border-bottom: 1px solid var(--line);
}
.lesson-section:last-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.lesson-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 20px;
}
.lesson-section-head h2 { margin: 0 0 7px; }
.lesson-section-head p { margin: 0; max-width: 760px; color: var(--muted); line-height: 1.6; }
.section-top-link {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  background: #fff;
}
.section-reference { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #fafcfb; }
.section-assessment { padding: 22px; border: 1px solid #ead9ac; border-radius: 16px; background: #fffdf6; }
.section-media { padding: 22px; border: 1px solid #d9e8e0; border-radius: 16px; background: #f8fbf9; }
.lesson-section-content > .text-body,
.lesson-section-content > .text-lead,
.lesson-section-content > .text-small,
.lesson-section-content > .text-muted,
.lesson-section-content > .markdown-content,
.lesson-section-content > .structured-list,
.lesson-section-content > .content-quote,
.lesson-section-content > .callout,
.collapsible-content > .text-body,
.collapsible-content > .text-lead,
.collapsible-content > .text-small,
.collapsible-content > .text-muted,
.collapsible-content > .markdown-content,
.collapsible-content > .structured-list,
.collapsible-content > .content-quote,
.collapsible-content > .callout {
  width: min(780px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.content-collapsible {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfb;
  overflow: clip;
}
.content-collapsible > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 18px;
  font-weight: 700;
  color: var(--text);
}
.content-collapsible > summary::-webkit-details-marker { display: none; }
.collapsible-chevron { margin-left: auto; position: absolute; right: 18px; display: grid; place-items: center; transition: transform .18s ease; }
.collapsible-chevron .ui-icon { width: 16px; height: 16px; }
.content-collapsible[open] > summary .collapsible-chevron { transform: rotate(180deg); }
.content-collapsible > summary small { padding-right: 28px; font-size: 13px; font-weight: 500; color: var(--muted); }
.collapsible-content { padding: 4px 18px 18px; }
.collapsible-source, .collapsible-reference { background: #f8faf9; }
.collapsible-source > summary::before { content: 'Aa'; display: inline-grid; place-items: center; width: 28px; height: 22px; margin-right: 8px; border-radius: 7px; background: #e7efe9; color: #315844; font-size: 11px; }
.collapsible-transcript > summary::before { content: 'CC'; display: inline-grid; place-items: center; width: 28px; height: 22px; margin-right: 8px; border-radius: 7px; background: #e9eef8; color: #405a89; font-size: 10px; }

.media-group { margin: 24px 0; }
.media-group-head { margin-bottom: 14px; }
.media-group-head h3 { margin: 0 0 5px; font-size: 20px; }
.media-group-head p { margin: 0; color: var(--muted); line-height: 1.6; }
.media-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.media-grid-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}
.media-grid-item .content-image { margin: 0; padding: 12px; align-items: stretch; }
.media-grid-item .content-image img { width: 100%; max-width: 100%; max-height: 260px; object-fit: contain; }
.media-image-open {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.media-image-open img { display: block; margin: 0 auto; }
.media-image-open-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(15,23,42,.78);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  transition: opacity .16s ease;
}
.media-image-open:hover .media-image-open-label, .media-image-open:focus-visible .media-image-open-label { opacity: 1; }
.media-grid-player .audio-block, .media-grid-player .video-block { margin: 0; border: 0; border-radius: 0; }

.media-playlist-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
}
.media-playlist-stage { min-width: 0; }
.media-playlist-stage .audio-block, .media-playlist-stage .video-block, .media-playlist-stage .content-image { margin: 0; }
.media-playlist-list {
  max-height: 540px;
  overflow-y: auto;
  display: grid;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f9fbfa;
}
.media-playlist-item {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.media-playlist-item:hover { background: #eef4f0; }
.media-playlist-item.active { background: #e2efe7; color: #245a43; }
.media-playlist-index { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: #fff; border: 1px solid var(--line); font-size: 12px; font-weight: 750; }
.media-playlist-copy { min-width: 0; }
.media-playlist-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.media-playlist-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.media-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(8,18,14,.78);
}
.media-viewer-backdrop.open { display: grid; }
body.media-viewer-open { overflow: hidden; }
.media-viewer {
  width: min(1180px, 96vw);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0,0,0,.32);
  overflow: hidden;
}
.media-viewer-head { min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.media-viewer-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-viewer-stage { min-height: 0; overflow: auto; display: grid; place-items: center; padding: 18px; background: #f3f5f4; }
.media-viewer-stage img { max-width: 100%; height: auto; max-height: calc(94vh - 92px); object-fit: contain; }

@media (max-width: 980px) {
  .lesson-section-nav { top: 76px; }
  .media-playlist-layout { grid-template-columns: 1fr; }
  .media-playlist-list { max-height: 280px; }
}
@media (max-width: 720px) {
  .lesson-section-nav { position: static; display: block; padding: 10px; }
  .lesson-section-nav-label { display: block; margin: 0 2px 7px; }
  .lesson-section-head { gap: 8px; }
  .section-top-link { display: none; }
  .section-reference, .section-assessment, .section-media { padding: 15px 12px; margin-left: -2px; margin-right: -2px; }
  .media-group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .media-grid-item .content-image { padding: 8px; }
  .media-grid-item .content-image img { max-height: 200px; }
  .media-viewer-backdrop { padding: 8px; }
  .media-viewer { width: 100%; max-height: 96vh; border-radius: 12px; }
}
@media (max-width: 420px) {
  .media-group-grid { grid-template-columns: 1fr; }
}
.content-collapsible > summary { position: relative; }

/* v0.14.6 — icon geometry and vertical centering */
.import-valid > span .ui-icon { width: 16px; height: 16px; }
.import-success-icon .ui-icon { width: 30px; height: 30px; }
.import-warning-list > div { display: flex; align-items: flex-start; gap: 8px; }
.import-warning-list .ui-icon { width: 17px; height: 17px; margin-top: 2px; }
.check-marker .ui-icon { width: 12px; height: 12px; }
.download-icon .ui-icon, .video-icon .ui-icon, .audio-icon .ui-icon { width: 21px; height: 21px; }
.section-top-link { display: grid; place-items: center; }
.section-top-link .ui-icon { width: 16px; height: 16px; }
.quiz-feedback-title span { display: inline-flex; align-items: center; gap: 6px; }
.quiz-feedback-title .ui-icon, .success-text .ui-icon, .badge .ui-icon { width: 14px; height: 14px; }
.success-text, .badge { align-items: center; }
.media-playlist-arrow { display: grid; place-items: center; }
.media-playlist-arrow .ui-icon { width: 15px; height: 15px; }
.content-external-link { display: inline-flex; align-items: center; gap: 6px; }
.content-external-link .ui-icon { width: 14px; height: 14px; }
.code-copy-icon { display: grid; place-items: center; }
.code-copy-icon .ui-icon { width: 15px; height: 15px; }


/* Assessment Player V2 */
.assessment-player {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.assessment-player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
}
.assessment-player-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.assessment-status-line { padding: 8px 16px 0; }
.assessment-timer {
  min-width: 82px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface-muted, #f5f7f6);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-weight: 800;
}
.assessment-timer.warning { background: #fff8e8; border-color: #ead7a3; color: #765600; }
.assessment-timer.danger { background: #fff0f0; border-color: #efc4c4; color: var(--danger); }
.assessment-save-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.assessment-save-status[data-state="saving"], .assessment-save-status[data-state="dirty"] { color: #765600; }
.assessment-save-status[data-state="saved"] { color: var(--success); }
.assessment-save-status[data-state="error"] { color: var(--danger); font-weight: 700; }
.assessment-navigator {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.assessment-nav-item {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}
.assessment-nav-item:hover { border-color: var(--primary); }
.assessment-nav-item.answered { background: #edf8f2; border-color: #b9dcc9; }
.assessment-nav-item.flagged::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c98a12;
  border: 2px solid var(--surface);
}
.assessment-nav-item.current { outline: 2px solid var(--primary); outline-offset: 1px; }
.assessment-question-stage { padding: 18px 18px 4px; }
.assessment-question-stage > .question { margin: 0; }
.assessment-question-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.assessment-question-actions [data-assessment-next] { justify-self: end; }
.assessment-flag.active { border-color: #d7a633; background: #fff8e8; color: #765600; }
.assessment-complete-row { padding: 0 18px 18px; display: flex; justify-content: flex-end; }
.assessment-submit-panel {
  margin: 0 18px 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted, #f7f8f7);
}
.assessment-submit-panel [data-assessment-submit-summary] { display: grid; gap: 4px; }
.assessment-submit-warning { margin-top: 6px; color: var(--danger); font-weight: 700; }
.assessment-submit-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.assessment-result-screen { margin-top: 16px; }
.assessment-result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.assessment-result-stats > div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
}
.assessment-result-stats strong { display: block; font-size: 20px; }
.assessment-result-stats span { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.assessment-result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.assessment-result-review { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.assessment-result-review > summary { padding: 12px 14px; cursor: pointer; font-weight: 750; background: var(--surface-muted, #f7f8f7); }
.assessment-result-review > .quiz-feedback { padding: 0 12px 12px; }
.assessment-timeout-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #fff8e8; color: #765600; }
.assessment-review { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.assessment-review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.assessment-review-head h4 { margin: 6px 0 2px; }
.assessment-review [data-assessment-review-questions] { display: grid; gap: 12px; }
.assessment-review [data-assessment-review-questions] .question { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.assessment-review [data-assessment-review-result] { margin: 12px 0; }
.assessment-admin-preview { margin-top: 12px; }

@media (max-width: 720px) {
  .assessment-player-head { align-items: flex-start; flex-direction: column; }
  .assessment-player-status { justify-content: flex-start; width: 100%; }
  .assessment-question-actions { grid-template-columns: 1fr 1fr; }
  .assessment-question-actions .assessment-flag { grid-column: 1 / -1; grid-row: 1; }
  .assessment-question-actions [data-assessment-prev] { grid-column: 1; grid-row: 2; }
  .assessment-question-actions [data-assessment-next] { grid-column: 2; grid-row: 2; justify-self: stretch; }
  .assessment-result-stats { grid-template-columns: 1fr; }
  .assessment-review-head { flex-direction: column; }
  .assessment-submit-actions { flex-direction: column; }
  .assessment-submit-actions .btn { width: 100%; }
}

/* Assessment Question Types V3 */
.matching-question { display: grid; gap: 12px; margin-top: 12px; }
.matching-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr); gap: 12px; align-items: center; }
.matching-left { min-width: 0; }
.ordering-question { display: grid; gap: 8px; margin-top: 12px; }
.ordering-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border, #d9e1dc); border-radius: 10px; background: var(--surface, #fff); }
.ordering-handle { color: var(--muted, #66776e); font-weight: 700; }
.ordering-actions { display: inline-flex; gap: 6px; }
.quiz-feedback-item.partial { border-left-color: #b7791f; }
@media (max-width: 700px) { .matching-row { grid-template-columns: 1fr; } .ordering-item { grid-template-columns: auto minmax(0, 1fr); } .ordering-actions { grid-column: 2; } }

/* Assessment Analytics */
.modal-analytics { width: min(1180px, 100%); }
.analytics-toolbar { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:18px; }
.analytics-export-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.analytics-summary-grid,
.analytics-metric-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.analytics-summary-grid { margin-bottom:20px; }
.analytics-summary-grid > div,
.analytics-metric-grid > div { padding:14px; border:1px solid var(--line); border-radius:12px; background:#f8fafc; }
.analytics-summary-grid span,
.analytics-metric-grid span { display:block; color:var(--muted); font-size:12px; }
.analytics-summary-grid strong,
.analytics-metric-grid strong { display:block; margin-top:4px; font-size:20px; }
.analytics-metric-grid small { display:block; margin-top:3px; color:var(--muted); }
.analytics-assessment-list { display:grid; gap:18px; }
.analytics-assessment-card { border:1px solid var(--line); border-radius:16px; padding:18px; background:#fff; }
.analytics-assessment-head,
.analytics-section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:14px; }
.analytics-assessment-head h3,
.analytics-history-section h3 { margin:2px 0 0; }
.analytics-metric-grid { margin-bottom:16px; }
.analytics-question-table td:first-child { min-width:260px; max-width:440px; }
.analytics-distribution { margin-top:8px; }
.analytics-distribution summary { cursor:pointer; color:var(--primary); font-weight:700; font-size:12px; }
.analytics-distribution-list { display:grid; gap:5px; margin-top:7px; }
.analytics-distribution-item { display:grid; grid-template-columns:minmax(100px,1fr) auto auto; gap:8px; align-items:center; font-size:12px; padding:6px 8px; border:1px solid var(--line); border-radius:8px; background:#fafafa; }
.analytics-distribution-item.correct { background:#f2f8f4; }
.analytics-distribution-item small { color:var(--muted); }
.analytics-history-section { margin-top:22px; padding-top:18px; border-top:1px solid var(--line); }
.analytics-old-version { color:var(--warning-text, #8a5a00); font-weight:700; }
.analytics-timing-note { margin-top:14px; padding:10px 12px; border-radius:10px; background:#f8fafc; }

@media (max-width: 820px) {
  .analytics-toolbar { align-items:flex-start; flex-direction:column; }
  .analytics-export-actions { width:100%; justify-content:stretch; }
  .analytics-export-actions .btn { flex:1 1 180px; }
  .analytics-summary-grid,
  .analytics-metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .analytics-assessment-card { padding:14px; }
}

@media (max-width: 520px) {
  .analytics-summary-grid,
  .analytics-metric-grid { grid-template-columns:1fr; }
  .analytics-assessment-head { flex-direction:column; }
  .analytics-distribution-item { grid-template-columns:1fr auto; }
  .analytics-distribution-item small { grid-column:1 / -1; }
}

/* === LaTeX / MathJax === */
.math-inline-source { white-space: nowrap; }
.math-display-source,
.latex-formula-render,
mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.math-display-source,
.latex-formula-render { padding: 8px 2px; }
.latex-formula {
  margin: 22px 0;
  border: 1px solid #d9e6e1;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdfc 0%, #f6faf8 100%);
  overflow: hidden;
}
.latex-formula-title { padding: 14px 18px 0; font-weight: 750; color: #243a34; }
.latex-formula-stage {
  min-height: 82px;
  display: grid;
  align-items: center;
  padding: 14px 18px 16px;
  background: #fff;
}
.latex-formula-render { text-align: center; font-size: 1.08em; }
.latex-formula-source { border-top: 1px solid #e2ebe7; padding: 10px 18px 14px; }
.latex-formula-source summary { cursor: pointer; color: #4d625b; font-weight: 700; }
.latex-formula-source pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #12211d;
  color: #eaf4f0;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.latex-copy { position: static; display: inline-flex; margin-top: 2px; }
mjx-container { line-height: 1.2; }
mjx-container svg { max-width: none; }

@media (max-width: 680px) {
  .latex-formula { border-radius: 13px; }
  .latex-formula-stage { padding: 12px 10px 14px; }
  .latex-formula-render { font-size: 1em; }
}
