:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --paper: #ffffff;
  --bg: #f1f5f9;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --good: #16a34a;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 800; font-size: 18px; }
.topbar button, .btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.wrap { max-width: 860px; margin: 0 auto; padding: 32px 20px 80px; }
.wrap.wide { max-width: 1100px; }
.center-wrap { max-width: 400px; margin: 60px auto; padding: 0 20px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 16px;
}
.card h2, .card h3 { margin-top: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; margin-bottom: 14px; }
/* Two fields side by side (signup's first/last name, admin's title/slug,
   category/level, etc.) squeeze to ~half of a phone's width otherwise —
   e.g. a course title input only wide enough to show two characters at a
   time. Full width, stacked, reads far better under ~480px. */
@media (max-width: 480px) { .field-row { flex-direction: column; gap: 0; } }
.error { color: #dc2626; font-size: 13.5px; margin-top: 10px; min-height: 1em; }
.hint { color: var(--ink-soft); font-size: 13.5px; margin-top: 14px; text-align: center; }
.hint a { cursor: pointer; text-decoration: underline; }

.progress-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-bar > div { height: 100%; background: var(--good); transition: width .2s ease; }
.progress-label { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

.course-card { display: block; text-decoration: none; color: inherit; }
.course-card:hover { border-color: var(--accent); }

.topic-type-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
  background: var(--bg); padding: 3px 8px; border-radius: 999px;
}
.back-link { display: inline-block; margin-bottom: 18px; font-size: 14px; }
.loading { color: var(--ink-soft); padding: 40px 0; text-align: center; }

/* Course player: content on the left, playlist + related content on the right. */
.course-layout { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
@media (max-width: 800px) { .course-layout { grid-template-columns: 1fr; } }

.right-rail { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 16px; }

.playlist {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  max-height: 55vh; overflow-y: auto;
}
.playlist-module { padding: 16px 6px 6px 16px; }
.playlist-module h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.playlist-topic {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 4px; margin-right: 10px;
  cursor: pointer; border-left: 3px solid transparent; border-radius: 0 8px 8px 0;
}
.playlist-topic:hover { background: var(--bg); }
.playlist-topic.is-active { background: var(--accent-soft); border-left-color: var(--accent); }
.playlist-topic .t-title { flex: 1; font-size: 13.5px; line-height: 1.3; }

/* Checkmark-style progress indicator: empty ring, filled + check when done. */
.progress-dot {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; flex: none; margin: 0;
  border: 2px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer;
  position: relative; transition: background .15s ease, border-color .15s ease;
}
.progress-dot:hover { border-color: var(--accent); }
.progress-dot:checked { background: var(--good); border-color: var(--good); }
.progress-dot:checked::after {
  content: ''; position: absolute; left: 50%; top: 45%; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg);
}
.progress-dot:disabled { cursor: not-allowed; opacity: .45; }
.progress-dot:disabled:hover { border-color: var(--line); }

.mark-done.is-locked { color: var(--ink-soft); cursor: not-allowed; }
.watch-gate-hint { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-soft); }

.content-panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; min-height: 320px; }
.content-panel iframe { width: 100%; aspect-ratio: 16/9; border: none; border-radius: 8px; margin: 14px 0 18px; display: block; }
.content-panel p { line-height: 1.6; color: var(--ink-soft); }

.quiz { margin-top: 8px; }
.quiz-question { margin-bottom: 22px; }
.quiz-q-text { font-weight: 700; margin: 0 0 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; cursor: pointer;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option.is-correct { border-color: var(--good); background: #dcfce7; }
.quiz-option.is-wrong { border-color: #dc2626; background: #fee2e2; }
.quiz-option input { flex: none; }
.quiz-result { padding: 12px 16px; border-radius: 8px; font-weight: 700; margin: 4px 0 14px; }
.quiz-result.is-pass { background: #dcfce7; color: #166534; }
.quiz-result.is-fail { background: #fee2e2; color: #991b1b; }

.resources { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.resources h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.resource-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 1px solid var(--line);
  border-radius: 8px; margin: 0 8px 8px 0; font-size: 13.5px; text-decoration: none;
}
.resource-link:hover { border-color: var(--accent); }

.related-content {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.related-content h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.related-content-link {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 8px; font-size: 13.5px; text-decoration: none; color: var(--ink);
}
.related-content-link:last-child { margin-bottom: 0; }
.related-content-link:hover { border-color: var(--accent); background: var(--bg); }
.related-content-link .rc-icon { flex: none; }

.mark-done {
  display: flex; align-items: center; gap: 10px; margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Course catalog: filters sidebar + search/sort toolbar + course rows. */
.catalog-header h1 { margin: 0 0 6px; }
.catalog-header p { margin: 0 0 22px; color: var(--ink-soft); }

.catalog-toolbar { display: flex; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.sort-select { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: var(--paper); max-width: 100%; }
/* A <select>'s width is driven by its longest <option> text, which doesn't
   shrink in a flex row on its own ("Sort by: Duration (shortest first)" was
   wide enough to push the page into horizontal scroll on a phone) — below
   this width it takes the full row instead of fighting the search box for space. */
@media (max-width: 480px) { .search-input, .sort-select { flex-basis: 100%; } }

.catalog-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .catalog-layout { grid-template-columns: 1fr; } }

.filters-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; position: sticky; top: 20px;
}
.filters-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.filters-title { font-weight: 700; font-size: 14px; }
.clear-filters { background: none; border: none; color: var(--accent); font-size: 12.5px; cursor: pointer; padding: 0; }
.filter-group { padding: 14px 0; }
.filter-group + .filter-group { border-top: 1px solid var(--line); }
.filter-group h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.filter-option { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 5px 0; cursor: pointer; }
.filter-option input { width: 15px; height: 15px; flex: none; }

.course-list { display: flex; flex-direction: column; gap: 16px; }
.course-row {
  display: flex; gap: 20px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
@media (max-width: 640px) { .course-row { flex-direction: column; } }
.course-thumb {
  width: 200px; aspect-ratio: 16/10; flex: none; border-radius: 8px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: var(--ink-soft); font-size: 12px; text-align: center; line-height: 1.4;
}
.course-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-info { flex: 1; min-width: 0; }
.course-info h3 { margin: 0 0 6px; font-size: 18px; }
.course-title-link { color: var(--ink); text-decoration: none; }
.course-title-link:hover { color: var(--accent); }
.course-info p { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.course-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.course-tag {
  font-size: 12px; background: var(--bg); color: var(--ink-soft); padding: 4px 10px; border-radius: 999px;
}
.course-tag.is-free { background: #dcfce7; color: #166534; font-weight: 700; }
.course-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.outline { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }

/* Gamification: account level, streak, per-line points, badges. */
.stats-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 22px;
}
.stats-top { display: flex; gap: 40px; flex-wrap: wrap; margin-bottom: 4px; }
.stat-block { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.stat-value { font-size: 22px; font-weight: 800; }
.stat-sub { font-size: 12.5px; color: var(--ink-soft); }
.tier-badge { color: var(--accent); }

.stat-lines { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.stat-line {
  display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px;
}
.stat-line-label { color: var(--ink-soft); }
.stat-line-value { font-weight: 700; }

.badges-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.badge-pill {
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 700;
}
.stats-panel-link { display: inline-block; margin-top: 14px; font-size: 13px; font-weight: 600; }

/* Account page */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.profile-static { font-size: 15px; padding: 10px 0; }
.success-msg { color: var(--good); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

.achievement-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line);
}
.achievement-row:first-child { border-top: none; padding-top: 0; }
.achievement-icon { font-size: 22px; flex: none; }
.achievement-title { font-weight: 700; font-size: 14.5px; }
.achievement-desc { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.achievement-date { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }

/* Course landing page (e-commerce style product page). */
.course-hero { display: grid; grid-template-columns: 1fr 1.3fr; gap: 32px; align-items: center; margin: 12px 0 40px; }
@media (max-width: 800px) { .course-hero { grid-template-columns: 1fr; } }
.course-hero-thumb {
  aspect-ratio: 16/10; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: var(--ink-soft); font-size: 13px; text-align: center; line-height: 1.4;
}
.course-hero-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-hero-copy h1 { margin: 10px 0 12px; font-size: 30px; line-height: 1.15; }
.course-hero-desc { color: var(--ink-soft); font-size: 15.5px; line-height: 1.6; margin: 0 0 16px; }
.course-price-row { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.course-price { font-size: 26px; font-weight: 800; }
.btn-lg { padding: 13px 22px; font-size: 15px; }

.landing-section { margin: 40px 0; padding-top: 32px; border-top: 1px solid var(--line); }
.landing-section h2 { margin: 0 0 16px; font-size: 20px; }
.learn-list { margin: 0; padding-left: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
@media (max-width: 640px) { .learn-list { grid-template-columns: 1fr; } }
.learn-list li { color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; }

.curriculum-module { margin-bottom: 20px; }
.curriculum-module h3 { font-size: 14px; margin: 0 0 8px; }
.curriculum-topic {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 6px; font-size: 14px;
}
.ct-icon { flex: none; }
.ct-title { flex: 1; }

.instructor-box { display: flex; gap: 16px; align-items: flex-start; }
.instructor-avatar {
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex: none;
}
.instructor-name { font-weight: 700; margin-bottom: 4px; }
.instructor-box p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin: 0; }

.faq-item { padding: 16px 0; border-top: 1px solid var(--line); }
.faq-item:first-of-type { border-top: none; padding-top: 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 15px; }
.faq-item p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.6; }

.landing-cta-banner {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; text-align: center; margin-top: 40px;
}
.landing-cta-banner p { margin: 0 0 16px; font-size: 17px; font-weight: 700; }
.cta-reassure { color: var(--ink-soft); font-size: 12.5px; margin-top: 10px; }

/* Onboarding: "what are you here for" picker right after signup. */
.card-wide { max-width: 480px; }
.onboarding-sub { color: var(--ink-soft); font-size: 14px; margin: -8px 0 20px; }
.onboarding-options { display: flex; flex-direction: column; gap: 10px; }
.onboarding-option {
  display: block; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; cursor: pointer; font: inherit; color: inherit;
}
.onboarding-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.onboarding-option-title { display: block; font-weight: 700; font-size: 14.5px; }
.onboarding-option-desc { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 3px; line-height: 1.4; }
.onboarding-skip { display: block; text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--ink-soft); }

/* Notes: free-form textarea per topic, autosaved. */
.notes-box { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.notes-box h4 { margin: 0 0 4px; font-size: 13px; color: var(--ink-soft); }
.notes-hint { margin: 0 0 10px; font-size: 12px; color: var(--ink-soft); }
.notes-textarea {
  width: 100%; min-height: 90px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13.5px; line-height: 1.5; resize: vertical;
}
.notes-textarea:focus { outline: none; border-color: var(--accent); }
.notes-status { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-soft); min-height: 1.4em; }

/* Course completion banner, shown above the player once every topic is done. */
.cert-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: #dcfce7; border: 1px solid #86efac; border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 22px;
}
.cert-banner strong { color: #166534; font-size: 15px; }
.cert-banner p { margin: 4px 0 0; color: #166534; font-size: 13px; }

/* Certificate page: the printable/downloadable document itself. */
.certificate-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 56px 40px; text-align: center; margin-top: 24px;
}
.certificate-kicker {
  display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent); font-weight: 700; margin-bottom: 24px;
}
.certificate-lede { color: var(--ink-soft); font-size: 14px; margin: 0; }
.certificate-name { font-size: 32px; margin: 8px 0 20px; }
.certificate-course { font-size: 22px; margin: 8px 0 18px; }
.certificate-date { color: var(--ink-soft); font-size: 13px; margin: 0 0 32px; }
.certificate-footer {
  display: flex; justify-content: space-between; align-items: center; padding-top: 24px;
  border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft);
}
.certificate-code { font-family: monospace; }
.certificate-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; }
.certificate-verify-note { text-align: center; color: var(--ink-soft); font-size: 12.5px; margin-top: 14px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .certificate-card { border: none; margin-top: 0; }
}

/* Admin panel */
.field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; resize: vertical;
}
.admin-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.admin-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.admin-row { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); overflow: hidden; }
.admin-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.admin-row-title { font-weight: 600; }
.admin-row-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.admin-row-actions { display: flex; gap: 8px; flex: none; }
.admin-row-actions button { padding: 6px 10px; font-size: 13px; }
.admin-row-body { padding: 0 16px 16px; border-top: 1px solid var(--line); background: var(--paper); }
.admin-nested { margin: 14px 0 0 18px; padding-left: 16px; border-left: 2px solid var(--line); }
.admin-danger { background: #fee2e2 !important; color: #991b1b !important; }
.admin-quiz-option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.admin-quiz-option-row input[type=text] { flex: 1; }
.admin-not-authorized { text-align: center; padding: 80px 20px; color: var(--ink-soft); }
.admin-video-source { display: flex; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.admin-video-source label { font-size: 14px; font-weight: normal; display: flex; align-items: center; gap: 6px; }
.admin-row-actions button[disabled] { opacity: .4; cursor: not-allowed; }

/* Course > module > topic is 3 levels of nesting, and each one's padding
   and .admin-nested indent stacks on the way in — fine on desktop, but on a
   375px phone the innermost topic form was left with barely 100px of usable
   width (a title input only wide enough for 2-3 characters at a time).
   Shrinking padding and dropping the indent guide on narrow screens trades
   a bit of visual hierarchy for a form that's actually usable. */
@media (max-width: 480px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px; }
  .admin-row-body { padding: 0 10px 10px; }
  .admin-nested { margin-left: 0; padding-left: 10px; border-left-width: 1px; }
}

.admin-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,.15);
}
.admin-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
