:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #18212f;
  --text-muted: #556275;
  --border: #e2e8f0;
  --primary: #1877f2;
  --primary-dark: #0f5ec7;
  --accent-bg: #eef5ff;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --warn-bg: #fffbeb;
  --warn-border: #f59e0b;
  --code-bg: #0f172a;
  --code-text: #f8fafc;
  --font-size: 17px;
}

body.dark {
  --bg: #0f141c;
  --surface: #171f2b;
  --surface-soft: #1e293b;
  --text: #e8eef7;
  --text-muted: #9aa7ba;
  --border: #2a3649;
  --primary: #4b9aff;
  --primary-dark: #2563eb;
  --accent-bg: #17253d;
  --success: #4ade80;
  --success-bg: #0d2b1d;
  --warn-bg: #2a210f;
  --warn-border: #d97706;
  --code-bg: #090d14;
  --code-text: #f1f5f9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans Sinhala', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* MULTI-PACKAGE LOGIN PORTAL */
.portal-login-shell {
  min-height: 100vh;
  padding: 28px 18px 48px;
  background: radial-gradient(circle at top left, #e0edff, var(--bg) 55%);
}

body.dark .portal-login-shell {
  background: radial-gradient(circle at top left, #17253d, var(--bg) 55%);
}

.portal-login-container {
  max-width: 1060px;
  margin: 0 auto;
}

.portal-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 28px;
  margin-bottom: 22px;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.05);
}

.hero-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.hero-logo {
  width: 48px !important;
  height: 48px !important;
  font-size: 19px !important;
  flex-shrink: 0;
}

.hero-title {
  margin: 0;
  font-size: 25px;
  line-height: 1.35;
  font-weight: 800;
}

.hero-sub {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--text-muted);
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.pkg-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pkg-card:hover {
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.09);
}

.pkg-v200k { border-top: 4px solid #0284c7; }
.pkg-yt { border-top: 4px solid #db2777; }
.pkg-fb {
  border-top: 4px solid #16a34a;
  border-color: #86efac;
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.08) 0%, var(--surface) 48%);
}
.pkg-combo {
  border-top: 4px solid #7c3aed;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.04) 0%, var(--surface) 45%);
}

.pkg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pkg-price-badge {
  font-size: 15px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
}

.pkg-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
}

.pkg-tag-hot {
  background: #fef3c7;
  color: #92400e;
}

.pkg-title {
  margin: 0 0 8px;
  font-size: 18.5px;
  line-height: 1.4;
  font-weight: 800;
}

.pkg-prompt {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-soft);
  padding: 10px 12px;
  border-radius: 10px;
  line-height: 1.65;
  font-weight: 600;
}

.pkg-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.pkg-login-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: auto;
}

.pkg-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
}

.pkg-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.14);
}

.pkg-btn {
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.pkg-btn:hover { opacity: 0.92; }
.pkg-btn:disabled { opacity: 0.6; cursor: wait; }

.portal-login-footer {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.portal-login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.brand-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--accent-bg);
  padding: 4px 11px;
  border-radius: 999px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.btn-primary:hover { background: var(--primary-dark); }

.alert-error {
  margin-top: 6px;
  padding: 11px 13px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13.5px;
  line-height: 1.65;
}

.switch-pkg-btn {
  display: inline-block;
  margin-top: 8px;
  background: #1877f2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.device-notice {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-muted);
}

.device-notice a { color: var(--primary); font-weight: 700; text-decoration: none; }

.admin-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

/* COURSE READER SHELL */
.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.site-title {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
}

.site-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.font-controls {
  display: flex;
  gap: 4px;
}

.chip-btn, .icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.student-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--primary);
  white-space: nowrap;
}

.mobile-only { display: none; }

/* SECTION SWITCHER BAR */
.section-bar-wrap {
  position: sticky;
  top: 62px;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
}

.section-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.section-tabs::-webkit-scrollbar { display: none; }

.sec-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sec-pill.active {
  color: #fff;
  border-color: transparent;
}

.sec-pill.locked {
  opacity: 0.62;
  background: transparent;
  border-style: dashed;
}

.sec-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.1);
}

.sec-pill.active .sec-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 114px);
}

/* SIDEBAR */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 14px 40px;
  height: calc(100vh - 114px);
  position: sticky;
  top: 114px;
  overflow-y: auto;
}

.progress-box {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  transition: width 0.25s ease;
}

.search-wrap input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 14px;
}

.module-group { margin-bottom: 16px; }

.module-heading {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 4px 8px;
  margin-bottom: 4px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface-soft); }

.nav-item.active {
  background: var(--accent-bg);
  color: var(--primary);
  font-weight: 700;
}

.nav-num {
  min-width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
  flex-shrink: 0;
}

.nav-item.done .nav-num {
  background: var(--success-bg);
  color: var(--success);
}

.nav-item.active .nav-num {
  background: var(--primary);
  color: #fff;
}

/* ARTICLE / VIDEO READER */
.reader-main {
  padding: 24px 22px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.article-card {
  width: 100%;
  max-width: 840px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 40px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.04);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.badge-module {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  background: var(--accent-bg);
  padding: 4px 12px;
  border-radius: 999px;
}

.badge-time {
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--surface-soft);
  padding: 4px 12px;
  border-radius: 999px;
}

.article-title {
  margin: 0 0 10px;
  font-size: 27px;
  line-height: 1.4;
  font-weight: 800;
}

.article-summary {
  margin: 0 0 18px;
  font-size: 15.5px;
  color: var(--text-muted);
}

.article-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0 26px;
}

.article-body {
  font-size: var(--font-size);
  line-height: 1.92;
  word-break: break-word;
}

.article-body h2 {
  margin-top: 30px;
  margin-bottom: 12px;
  font-size: 1.32em;
  line-height: 1.45;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.article-body h3 {
  margin-top: 22px;
  margin-bottom: 10px;
  font-size: 1.12em;
  color: var(--primary);
}

.article-body p { margin: 0 0 15px; }
.article-body ul, .article-body ol { margin: 0 0 18px; padding-left: 24px; }
.article-body li { margin-bottom: 8px; }
.article-body a { color: var(--primary); font-weight: 600; word-break: break-word; }

/* RESPONSIVE VIMEO / VIDEO EMBEDS */
.article-body .wp-block-embed,
.article-body figure.wp-block-embed {
  margin: 22px 0;
  padding: 0;
  width: 100%;
  float: none !important;
}

.article-body .embed-vimeo,
.article-body .video-responsive {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.article-body .embed-vimeo iframe,
.article-body .video-responsive iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/* DRIVE / RESOURCE LINK CARDS (for Video 200,000 Pack & Downloads) */
.resource-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  margin: 9px 0;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  text-decoration: none !important;
  color: var(--text) !important;
  font-weight: 700;
  font-size: 15px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.resource-link-card:hover {
  border-color: var(--primary);
  background: var(--accent-bg);
}

.resource-link-pill {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}

.article-body blockquote {
  margin: 22px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--warn-border);
  background: var(--warn-bg);
  border-radius: 0 12px 12px 0;
}

.article-body blockquote p:last-child { margin-bottom: 0; }

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 0.92em;
  display: block;
  overflow-x: auto;
}

.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.article-body th {
  background: var(--surface-soft);
  font-weight: 700;
}

.article-body code {
  background: var(--surface-soft);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}

/* PROMPT COPY BOX */
.prompt-box {
  margin: 20px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #334155;
  background: var(--code-bg);
  color: var(--code-text);
}

.prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #1e293b;
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

.copy-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.prompt-box pre {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.65;
}

/* SCREENSHOT FIGURE */
.shot-figure {
  margin: 26px 0;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.shot-figure img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  cursor: zoom-in;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.shot-figure figcaption {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ACTIONS & PAGER */
.article-actions {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.btn-complete {
  padding: 13px 22px;
  border-radius: 12px;
  border: 1.5px solid var(--success);
  background: var(--success-bg);
  color: var(--success);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-complete.done {
  background: var(--success);
  color: #fff;
}

.chapter-pager {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pager-btn {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.pager-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.watermark-tag {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
  text-align: center;
}

/* MODALS */
.lightbox, .modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 15, 25, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.upgrade-prices {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lightbox img {
  max-width: 96vw;
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 20px;
  background: #fff;
  color: #111;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

.lightbox-caption {
  margin-top: 12px;
  color: #e2e8f0;
  font-size: 14px;
  text-align: center;
}

/* MOBILE */
.sidebar-backdrop {
  position: fixed;
  inset: 112px 0 0 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 45;
}

@media (max-width: 900px) {
  .packages-grid { grid-template-columns: 1fr; gap: 14px; }
  .portal-login-shell { padding: 14px 12px 36px; }
  .portal-hero { padding: 18px 16px; border-radius: 16px; }
  .hero-title { font-size: 20px; }
  .pkg-card { padding: 18px 16px; }
  .pkg-title { font-size: 17px; }

  .mobile-only { display: inline-flex; align-items: center; gap: 5px; }
  .topbar { padding: 0 10px; }
  .site-sub { display: none; }
  .site-title { font-size: 14px; }
  .font-controls { display: none; }
  .student-badge { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -340px;
    top: 112px;
    height: calc(100vh - 112px);
    width: 85vw;
    max-width: 320px;
    z-index: 50;
    transition: left 0.2s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.22);
  }
  .sidebar.open { left: 0; }
  .reader-main { padding: 14px 10px 44px; }
  .article-card { padding: 18px 14px; border-radius: 14px; }
  .article-title { font-size: 20.5px; line-height: 1.45; }
  .article-body { font-size: 16px; line-height: 1.9; }
  .shot-figure { margin: 18px -4px; padding: 8px; }
  .chapter-pager { flex-direction: column; }
  .pager-btn { width: 100%; padding: 14px; font-size: 15px; }
}
