/* The base look of the engine's components (.cb-*) and its neutral pages (the placeholder, errors).
   Components take their colors from the theme's variables (tokens.css); without a theme the values are neutral. */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.cb-btn, .cb-apply, .cb-complete, .cb-logout {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--r-md, 12px); font: 600 15px/1.2 var(--f-body, system-ui, sans-serif);
  cursor: pointer; text-decoration: none; text-align: center;
  transition: box-shadow .15s ease, background-color .15s ease, border-color .15s ease;
}
.cb-btn--primary, .cb-apply, .cb-complete { background: var(--accent, #1f4fd1); color: var(--on-accent, #fff); }
.cb-btn--ghost, .cb-logout {
  background: transparent; color: var(--text, #111); border-color: var(--line-2, rgba(0, 0, 0, .2));
}
.cb-btn:disabled, .cb-complete:disabled, .cb-logout:disabled { opacity: .6; cursor: not-allowed; }
.cb-apply--disabled { background: var(--surface-3, #e6e6e6); color: var(--text-2, #555); cursor: default; }
.cb-complete--done { background: var(--surface-3, #e6e6e6); color: var(--text, #111); }
.cb-input {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: var(--r-sm, 10px);
  border: 1px solid var(--line-2, rgba(0, 0, 0, .2)); background: var(--surface-1, #fff); color: var(--text, #111);
  font: 16px/1.3 var(--f-body, system-ui, sans-serif);
}
.cb-label { display: grid; gap: 6px; font: 600 14px/1.3 var(--f-body, system-ui, sans-serif); color: var(--text-2, #555); }
.cb-hint, .cb-note { margin: 0; color: var(--text-3, #777); font-size: 13px; }
.cb-tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--surface-2, #f1f1f1); color: var(--text-2, #555); font: 600 11px/1 var(--f-mono, monospace);
  letter-spacing: .04em; white-space: nowrap;
}
.cb-tag--done { background: var(--accent, #1f4fd1); color: var(--on-accent, #fff); }
.cb-tag--locked { background: transparent; border: 1px solid var(--line-2, rgba(0, 0, 0, .2)); }

/* A course card */
.cb-course-card {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; height: 100%; padding: 12px;
  border-radius: var(--r-lg, 16px); background: var(--surface-1, #f6f6f6); color: var(--text, #111);
}
.cb-course-card-link { display: flex; flex-direction: column; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.cb-course-card-cover, .cb-course-card-nocover {
  display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; border-radius: var(--r-md, 12px); object-fit: cover;
}
.cb-course-card-nocover {
  display: flex; align-items: center; justify-content: center; background: var(--surface-2, #e9e9e9);
  font: 800 48px/1 var(--f-display, system-ui, sans-serif); color: var(--text-3, #888);
}
.cb-course-card-body { display: grid; gap: 6px; min-width: 0; }
.cb-course-card-title { font: 700 18px/1.25 var(--f-display, system-ui, sans-serif); overflow-wrap: anywhere; }
.cb-course-card-subtitle { color: var(--text-2, #555); font-size: 14px; overflow-wrap: anywhere; }
.cb-course-card-meta { color: var(--text-3, #777); font: 500 12px/1.4 var(--f-mono, monospace); }
.cb-course-card-enrolled { color: var(--accent, #1f4fd1); font-weight: 700; font-size: 13px; }

/* Progress */
.cb-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.cb-progress-bar {
  width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; appearance: none;
  background: var(--surface-3, #e1e1e1); color: var(--accent, #1f4fd1);
}
.cb-progress-bar::-webkit-progress-bar { background: var(--surface-3, #e1e1e1); border-radius: 999px; }
.cb-progress-bar::-webkit-progress-value { background: var(--accent, #1f4fd1); border-radius: 999px; }
.cb-progress-bar::-moz-progress-bar { background: var(--accent, #1f4fd1); border-radius: 999px; }
.cb-progress-text { color: var(--text-2, #555); font: 600 12px/1 var(--f-mono, monospace); white-space: nowrap; }

/* The program of a course */
.cb-program { display: grid; gap: 16px; color: var(--text, #111); }
.cb-program-modules, .cb-program-lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cb-program-module { display: grid; gap: 10px; padding: 16px; border-radius: var(--r-md, 12px); background: var(--surface-1, #f6f6f6); }
.cb-program-module-title { margin: 0; display: flex; gap: 12px; align-items: baseline; font: 700 17px/1.3 var(--f-display, system-ui, sans-serif); overflow-wrap: anywhere; }
.cb-program-module-n { color: var(--accent, #1f4fd1); font: 700 13px/1 var(--f-mono, monospace); }
.cb-program-lesson {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-sm, 10px); background: var(--surface-2, #eee);
}
.cb-program-lesson--current { box-shadow: inset 0 0 0 2px var(--accent, #1f4fd1); }
.cb-program-lesson-link, .cb-program-lesson-title { min-width: 0; overflow-wrap: anywhere; color: inherit; font-weight: 600; }
.cb-program-lesson-link { text-decoration: underline; text-underline-offset: 3px; }
.cb-program-lesson--locked .cb-program-lesson-title { color: var(--text-3, #777); }
.cb-program-lesson-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-program-empty { margin: 0; color: var(--text-3, #777); }

/* A lesson */
.cb-lesson { display: grid; gap: 20px; min-width: 0; color: var(--text, #111); font: 17px/1.6 var(--f-body, system-ui, sans-serif); }
.cb-lesson h2, .cb-lesson h3 { margin: 8px 0 0; font-family: var(--f-display, system-ui, sans-serif); line-height: 1.25; }
.cb-lesson p, .cb-lesson ul, .cb-lesson ol { margin: 0 0 12px; }
.cb-lesson ul, .cb-lesson ol { padding-left: 24px; }
.cb-lesson code { font-family: var(--f-mono, monospace); font-size: .9em; padding: 1px 5px; border-radius: 6px; background: var(--surface-2, #eee); }
.cb-link { color: var(--accent, #1f4fd1); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.cb-block { min-width: 0; }
.cb-text > :last-child { margin-bottom: 0; }
.cb-callout { padding: 16px 18px; border-radius: var(--r-md, 12px); background: var(--surface-2, #eef2ff); border-left: 4px solid var(--accent, #1f4fd1); }
.cb-callout-title { font-weight: 700; }
.cb-callout > :last-child { margin-bottom: 0; }
.cb-code { margin: 0; border-radius: var(--r-md, 12px); background: var(--surface-1, #f4f4f4); overflow: hidden; }
.cb-code-lang { padding: 8px 14px 0; color: var(--text-3, #777); font: 600 12px/1 var(--f-mono, monospace); }
.cb-code pre { margin: 0; padding: 12px 14px 14px; overflow-x: auto; }
.cb-code pre code { padding: 0; background: transparent; font-size: 14px; white-space: pre; }
.cb-image { margin: 0; display: grid; gap: 8px; }
.cb-image img { width: 100%; height: auto; border-radius: var(--r-md, 12px); }
.cb-image figcaption, .cb-player-caption { color: var(--text-3, #777); font-size: 14px; }
.cb-image-missing { display: block; padding: 24px; border-radius: var(--r-md, 12px); background: var(--surface-2, #eee); color: var(--text-3, #777); }
.cb-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.cb-file-link { color: var(--accent, #1f4fd1); font-weight: 700; overflow-wrap: anywhere; }
.cb-file-size, .cb-file-caption { color: var(--text-3, #777); font-size: 14px; }
.cb-lesson-locked { padding: 24px; border-radius: var(--r-md, 12px); background: var(--surface-1, #f6f6f6); }
.cb-lesson-locked-title { font-weight: 700; }
.cb-lesson-empty { color: var(--text-3, #777); }

.cb-player { margin: 0; display: grid; gap: 8px; }
.cb-player-screen {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; overflow: hidden; position: relative;
  border-radius: var(--r-md, 12px); background: var(--surface-3, #222); color: var(--text-2, #ddd);
}
.cb-player-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .45; }
.cb-player-soon { position: relative; margin: 0; padding: 0 16px; font-weight: 600; text-align: center; }
.cb-player-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cb-player[data-cb-state="error"] .cb-player-video { visibility: hidden; }
.cb-player-status {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; margin: 0; padding: 16px; background: inherit; color: inherit; font-weight: 600; text-align: center;
}
.cb-player-duration { margin: 0; color: var(--text-3, #777); font: 600 13px/1.2 var(--f-mono, monospace); }
.cb-quiz, .cb-homework { display: grid; gap: 6px; padding: 18px; border-radius: var(--r-md, 12px); border: 1px dashed var(--line-2, rgba(0, 0, 0, .25)); }
.cb-quiz-title, .cb-homework-title { margin: 0; font-weight: 700; }
.cb-quiz-body, .cb-homework-body, .cb-quiz-form, .cb-homework-form, .cb-homework-comment-form { display: grid; gap: 12px; }
.cb-quiz-name, .cb-homework-name { margin: 0; font: 700 18px/1.3 var(--f-display, system-ui, sans-serif); }
.cb-quiz-facts, .cb-quiz-hint, .cb-homework-meta, .cb-quiz-status, .cb-homework-status { margin: 0; color: var(--text-3, #777); font-size: 14px; }
.cb-quiz-required, .cb-homework-required { margin: 0; color: var(--text-2, #555); font-weight: 600; }
.cb-quiz-result, .cb-homework-state { margin: 0; font-weight: 700; color: var(--warn, #b3261e); }
.cb-quiz-result--passed, .cb-homework-state--accepted { color: var(--accent, #1f4fd1); }
.cb-homework-state--submitted { color: var(--text-2, #555); }
.cb-quiz-timer { margin: 0; font: 700 16px/1.2 var(--f-mono, monospace); }
.cb-quiz-question { display: grid; gap: 8px; margin: 0; padding: 14px; border: 1px solid var(--line-1, rgba(0, 0, 0, .12)); border-radius: var(--r-md, 12px); min-width: 0; }
.cb-quiz-legend { padding: 0 4px; font-weight: 700; }
.cb-quiz-text p, .cb-homework-text p { margin: 0; }
.cb-quiz-option { display: flex; gap: 8px; align-items: baseline; overflow-wrap: anywhere; }
.cb-homework-answer, .cb-homework-body-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cb-homework-label { margin: 0; font-weight: 700; }
.cb-homework-file-list, .cb-homework-comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cb-homework-comment { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--r-md, 12px); background: var(--surface-1, #f6f6f6); }
.cb-homework-textarea { min-height: 120px; }

.cb-lesson-nav { display: flex; flex-wrap: wrap; align-items: stretch; gap: 12px; }
.cb-lesson-nav-link {
  display: grid; gap: 4px; flex: 1 1 220px; min-width: 0; padding: 12px 16px; border-radius: var(--r-md, 12px);
  background: var(--surface-1, #f6f6f6); color: var(--text, #111); text-decoration: none;
}
.cb-lesson-nav-link--next { text-align: right; }
.cb-lesson-nav-hint { color: var(--text-3, #777); font: 600 12px/1.2 var(--f-mono, monospace); }
.cb-lesson-nav-title { font-weight: 700; overflow-wrap: anywhere; }
.cb-lesson-nav-back { align-self: center; color: var(--text-2, #555); }
.cb-complete { flex: 1 1 220px; }

/* The sign-in and devices */
.cb-login { display: grid; gap: 16px; max-width: 440px; color: var(--text, #111); font-family: var(--f-body, system-ui, sans-serif); }
.cb-login-step { display: grid; gap: 14px; }
.cb-login-title { margin: 0; font: 700 20px/1.3 var(--f-display, system-ui, sans-serif); }
.cb-login-text { margin: 0; color: var(--text-2, #555); }
.cb-login-error { margin: 0; color: var(--warn, #b3261e); font-weight: 600; }
.cb-devices { display: grid; gap: 12px; color: var(--text, #111); }
.cb-devices-note, .cb-devices-empty { margin: 0; color: var(--text-2, #555); }
.cb-devices-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cb-device {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px;
  border-radius: var(--r-md, 12px); background: var(--surface-1, #f6f6f6);
}
.cb-device-label { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.cb-device-meta { flex: 1 1 100%; color: var(--text-3, #777); font-size: 13px; }
.cb-community, .cb-cert { display: grid; gap: 8px; padding: 24px; border-radius: var(--r-lg, 16px); background: var(--surface-1, #f6f6f6); color: var(--text, #111); }
.cb-community-title, .cb-cert-status { margin: 0; font: 700 20px/1.3 var(--f-display, system-ui, sans-serif); }
.cb-community-text, .cb-cert-text { margin: 0; color: var(--text-2, #555); }

/* The community: spaces, posts, comments, forms */
.cb-community { gap: 16px; }
.cb-community-spaces { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-community-space { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-2, rgba(0, 0, 0, .2)); color: var(--text-2, #555); text-decoration: none; font-weight: 600; font-size: 14px; }
.cb-community-space--on { background: var(--accent, #1f4fd1); border-color: var(--accent, #1f4fd1); color: var(--on-accent, #fff); }
.cb-form { display: grid; gap: 10px; }
.cb-form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-textarea { min-height: 88px; resize: vertical; font: inherit; }
.cb-posts, .cb-comment-list, .cb-replies { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cb-post { display: grid; gap: 10px; padding: 16px; border-radius: var(--r-md, 12px); background: var(--bg, #fff); border: 1px solid var(--line-2, rgba(0, 0, 0, .12)); }
.cb-post-head, .cb-comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.cb-author { font-weight: 700; overflow-wrap: anywhere; }
.cb-when { color: var(--text-3, #777); font-size: 13px; }
.cb-md { overflow-wrap: anywhere; }
.cb-md > :first-child { margin-top: 0; }
.cb-md > :last-child { margin-bottom: 0; }
.cb-md p, .cb-md ul, .cb-md ol, .cb-md blockquote, .cb-md pre { margin: 0 0 10px; }
.cb-md ul, .cb-md ol { padding-left: 22px; }
.cb-md blockquote { padding-left: 12px; border-left: 3px solid var(--line-2, rgba(0, 0, 0, .25)); color: var(--text-2, #555); }
.cb-md code { padding: 1px 5px; border-radius: 6px; background: var(--surface-2, #eee); font: 0.92em var(--f-mono, monospace); }
.cb-md pre { padding: 12px; border-radius: var(--r-md, 12px); background: var(--surface-2, #eee); overflow-x: auto; }
.cb-md pre code { padding: 0; background: transparent; }
.cb-md a { color: var(--accent, #1f4fd1); text-decoration: underline; text-underline-offset: 3px; }
.cb-post-tools, .cb-comment-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 14px; }
.cb-reactions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.cb-react { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2, rgba(0, 0, 0, .2)); background: transparent; color: var(--text-2, #555); font: 600 13px/1.3 var(--f-body, system-ui, sans-serif); cursor: pointer; }
.cb-react--on { background: var(--accent, #1f4fd1); border-color: var(--accent, #1f4fd1); color: var(--on-accent, #fff); }
.cb-link-btn { display: inline; padding: 0; border: 0; background: transparent; color: var(--text-2, #555); font: 600 13px/1.3 var(--f-body, system-ui, sans-serif); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.cb-link-btn--warn { color: var(--warn, #b3261e); }
.cb-edit, .cb-report, .cb-reply { display: block; flex: 1 1 100%; }
.cb-edit[open], .cb-report[open], .cb-reply[open] { display: grid; gap: 10px; padding: 10px 0; }
.cb-comments { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line-2, rgba(0, 0, 0, .12)); }
.cb-comments-title { margin: 0; color: var(--text-3, #777); font-weight: 700; font-size: 14px; }
.cb-comment { display: grid; gap: 6px; }
.cb-replies { margin-top: 8px; padding-left: 18px; border-left: 2px solid var(--line-2, rgba(0, 0, 0, .12)); }
.cb-community-more { justify-self: start; }
.cb-tag--school { background: var(--accent, #1f4fd1); color: var(--on-accent, #fff); }
.cb-tag--warn { background: var(--warn, #b3261e); color: #fff; }
.cb-certs { display: grid; gap: 10px; margin-top: 24px; color: var(--text, #111); }
.cb-certs-title { margin: 0; font: 700 20px/1.3 var(--f-display, system-ui, sans-serif); }
.cb-certs-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cb-cert-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 12px 14px; border-radius: var(--r-md, 12px); background: var(--surface-1, #f6f6f6); }
.cb-cert-item-course { font-weight: 700; flex: 1 1 100%; }
.cb-cert-item-meta, .cb-cert-item-wait { color: var(--text-3, #777); font-size: 13px; }
.cb-cert--valid .cb-cert-status { color: var(--accent, #1f4fd1); }
.cb-cert--revoked .cb-cert-status, .cb-cert--missing .cb-cert-status { color: var(--warn, #b3261e); }
.cb-cert-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 8px 0 0; }
.cb-cert-facts dt { color: var(--text-3, #777); }
.cb-cert-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* The frame */
.cb-preview-banner {
  position: sticky; top: 0; z-index: 50; padding: 8px 16px; text-align: center;
  background: var(--warn, #ffb020); color: #111; font: 600 13px/1.3 var(--f-body, system-ui, sans-serif);
}
.cb-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: var(--r-md, 12px); background: var(--text, #111); color: var(--bg, #fff);
  font: 600 14px/1.3 var(--f-body, system-ui, sans-serif);
}

/* Neutral pages of the engine */
.cb-neutral { min-height: 100vh; display: grid; place-items: center; background: #f7f7f8; color: #111; font: 16px/1.5 system-ui, sans-serif; }
.cb-neutral-main { display: grid; gap: 12px; max-width: 520px; padding: 32px; text-align: center; justify-items: center; }
.cb-neutral-title { margin: 0; font-size: 28px; line-height: 1.2; }
.cb-neutral-name { margin: 0; color: #555; font-weight: 600; }
.cb-neutral .cb-btn--primary { background: #1f4fd1; color: #fff; }
