/* TrustSource Training — learner app
   Fresh skeleton; visual language matches ts-app (dark teal chrome, teal accent). */

:root {
  --navy:        #0e3d4a;
  --navy-deep:   #0a2d37;
  --navy-soft:   #1a4e5c;
  --teal:        #3BBFAD;
  --teal-dark:   #2ea094;
  --teal-light:  #d9f1ee;
  --bg:          #f6f7f9;
  --panel:       #ffffff;
  --border:      #e3e7eb;
  --border-dark: #cfd6dc;
  --text:        #1e2a32;
  --muted:       #6a7680;
  --danger:      #c43a3a;
  --danger-bg:   #fdeaea;
  --shadow:      0 1px 2px rgba(14, 61, 74, 0.06), 0 4px 12px rgba(14, 61, 74, 0.04);
  --radius:      6px;
  --radius-sm:   4px;
  --topbar-h:    56px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must trump any later display rule we
   assign for layout purposes (e.g. .video-placeholder { display: flex }). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------------------------------------------------- Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  background: var(--panel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--navy);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
}
.brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--teal);
  padding: 0.15rem 0.55rem;
  border: 1px solid rgba(59, 191, 173, 0.5);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.user-area {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.user-info {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.user-name {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.user-role {
  font-size: 0.72rem;
  color: var(--muted);
}

/* -------------------------------------------------- Account menu */

.user-menu { position: relative; }
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.user-menu-trigger:hover { background: var(--bg); }
.user-menu-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 191, 173, 0.35);
}
.user-menu-caret {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 120ms ease;
}
.user-menu-trigger[aria-expanded="true"] .user-menu-caret {
  transform: rotate(180deg);
}
.user-menu-pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 12rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.user-menu-item:hover {
  background: var(--bg);
  text-decoration: none;
}
.my-purchases-empty {
  color: var(--muted);
  padding: 0.6rem 0;
}

/* -------------------------------------------------- Section header band */

.section-header {
  background: var(--navy);
  color: #ffffff;
  padding: 1rem 1.5rem;
  border-bottom: 3px solid var(--teal);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.section-header-text { min-width: 0; }
.section-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.section-subtitle {
  margin: 0.15rem 0 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}
.back-link {
  color: var(--teal);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.back-link:hover { text-decoration: underline; }

/* -------------------------------------------------- Page + panels */

.page {
  padding: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.panel-center {
  max-width: 480px;
  margin: 4rem auto;
  text-align: center;
}
.panel-center h2 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Welcome card */
.welcome-mark {
  height: 48px;
  width: auto;
  display: inline-block;
  margin-bottom: 0.5rem;
}
.auth-buttons {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* -------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 80ms ease, color 80ms ease, border-color 80ms ease;
  background: transparent;
  color: inherit;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
}
.btn-secondary {
  background: var(--panel);
  color: var(--navy);
  border-color: var(--border-dark);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--navy);
}
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border-color: var(--border-dark);
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--navy-deep);
  border-color: var(--navy);
}
.btn-icon {
  height: 1em;
  width: 1em;
}

/* -------------------------------------------------- Alerts */

.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-top: 1rem;
  text-align: left;
}
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f4c7c7;
}

/* -------------------------------------------------- Course grid */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.course-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: box-shadow 120ms ease, transform 120ms ease;
  cursor: pointer;
}
.course-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.course-card-thumb {
  position: relative;
  height: 140px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  font-size: 2.4rem;
}
.course-card-status {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  box-shadow: 0 1px 4px rgba(13, 27, 42, 0.30);
}
.course-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.course-card-glyph {
  font-size: 2.4rem;
  color: var(--teal);
}
.course-card-body {
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}
.course-card-pricing {
  display: flex;
  align-items: center;
  min-height: 1.4rem;
}
.course-card-body h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(2 * 1.3em);
}
.course-card-desc {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(3 * 1.45em);
}
.course-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  min-height: 1.4rem;
}
.course-card-instructor {
  margin: 0;
  font-size: 0.8rem;
}

/* -------------------------------------------------- Pill / badge */

.pill {
  display: inline-block;
  background: var(--teal-light);
  color: var(--teal-dark);
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill-success  { background: #d9efe1; color: #1f6a42; }
.pill-progress { background: #e7eef3; color: var(--navy); }
.pill-lang     { background: #eaecef; color: #4d5a63; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.badge.enrolled { background: #d9efe1; color: #1f6a42; }
.badge.price    { background: var(--navy); color: #ffffff; }
.badge.free     { background: var(--teal-light); color: var(--teal-dark); }

/* -------------------------------------------------- Course filters */

.filter-bar {
  margin: 0 0 1.25rem 0;
}
.filter-row {
  border: 0;
  margin: 0 0 0.85rem 0;
  padding: 0;
  min-width: 0;
}
.filter-row:last-of-type { margin-bottom: 0; }
.filter-row-label {
  display: block;
  margin: 0 0 0.4rem 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5a6570;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.filter-pill {
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--navy);
  padding: 0.35rem 0.9rem;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  transition: background-color 80ms ease, color 80ms ease, border-color 80ms ease, box-shadow 80ms ease;
}
.filter-pill:hover:not(.pill-active) { border-color: var(--teal-dark); }
.filter-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 191, 173, 0.35);
}
.pill-active {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
}
.pill-active:hover { background: var(--navy-deep); border-color: var(--navy-deep); }

.filter-count {
  margin: 0 0 1rem 0;
  font-size: 0.85rem;
  color: #5a6570;
}
#courses-no-match .btn { margin-top: 0.75rem; }

/* -------------------------------------------------- Spinner */

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 0.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------- Utility */

.muted { color: var(--muted); }

/* -------------------------------------------------- Footer */

.pagefoot {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--panel);
}

/* -------------------------------------------------- Clickable card wrapper */

.course-card-link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
  outline: none;
}
.course-card-link:hover { text-decoration: none; }
.course-card-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 191, 173, 0.35);
}

/* -------------------------------------------------- My purchases list */

.my-purchases-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.my-purchases-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}
.my-purchases-item:last-child { border-bottom: none; }
.my-purchases-item a { flex: 1; }
.my-purchases-meta { color: var(--muted); font-size: 0.85rem; }
.my-purchases-refunded { opacity: 0.55; }

/* -------------------------------------------------- Course landing (overview) */

.course-landing {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

.landing-main {
  min-width: 0;
}

.landing-sidebar {
  position: sticky;
  top: 1rem;
}

.sidebar-card {
  padding: 1rem;
}

.sidebar-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 2.2rem;
  overflow: hidden;
  margin-bottom: 1rem;
}
.sidebar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-cta {
  display: block;
  width: 100%;
  background: var(--teal);
  color: #ffffff;
  border: 1px solid var(--teal);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease;
  margin-bottom: 1rem;
}
.btn-cta:hover:not(:disabled) {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

/* Teal accent for celebratory actions that sit alongside other buttons
   (e.g. "View results" in the course nav row). Same colour as .btn-cta
   but uses inline/auto width instead of full-bleed. */
.btn-accent {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}
.btn-accent:hover:not(:disabled) {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.sidebar-meta {
  margin: 0;
  font-size: 0.85rem;
}
.sidebar-meta > div {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.sidebar-meta > div:last-child { border-bottom: 0; }
.sidebar-meta dt {
  font-weight: 600;
  color: var(--navy);
}
.sidebar-meta dd {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

/* -------------------------------------------------- Tabs */

.tabs-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0.75rem 0 1rem 0;
}
.tabs-bar .tabs {
  border-bottom: none;
  margin: 0;
}
.back-link-tab {
  padding: 0.55rem 1rem;
  font-size: inherit;
  margin-bottom: -1px;
}
.toc-back {
  margin: 0 0 0.5rem 0;
}
.toc-back .back-link {
  font-size: 0.85rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin: 0.75rem 0 1rem 0;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--navy); }
.tab.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
  font-weight: 600;
}
.tab-content { margin-top: 0; }
.tab-content h2 { margin: 0 0 0.5rem 0; color: var(--navy); }
.tab-content h4 { margin: 1rem 0 0.35rem 0; color: var(--navy); font-size: 0.95rem; }

.ov-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* -------------------------------------------------- Results tab */

.results-hero {
  text-align: center;
  padding: 1.25rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.results-hero h2 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.5rem;
  color: var(--navy);
}
.results-hero p { margin: 0; }
.results-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #ffffff;
  font-size: 2rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(59, 191, 173, 0.35);
}

.results-section {
  margin-bottom: 1.25rem;
}
.results-section h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--navy);
}

.quiz-results {
  list-style: none;
  margin: 0;
  padding: 0;
}
.quiz-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--panel);
}
.quiz-result-main  {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.quiz-result-title { font-weight: 600; color: var(--navy); }
.quiz-result-score { font-size: 0.85rem; }
.quiz-result-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.quiz-badge-pass { background: #d9efe1; color: #1f6a42; }
.quiz-badge-fail { background: #f4e1e1; color: #8a2e2e; }

.results-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* -------------------------------------------------- Certificate card */

.cert-card {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  background: linear-gradient(135deg, #f7fbfa 0%, #eef6f4 100%);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  position: relative;
}
.cert-ribbon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 6px 16px rgba(59, 191, 173, 0.35);
  align-self: center;
}
.cert-body {
  flex: 1 1 auto;
  min-width: 0;
}
.cert-label {
  margin: 0 0 0.15rem 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal-dark);
  font-weight: 700;
}
.cert-course {
  margin: 0 0 0.1rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
}
.cert-learner {
  margin: 0 0 0.5rem 0;
  color: var(--text);
}
.cert-date, .cert-id {
  margin: 0;
  font-size: 0.82rem;
}
.cert-id code {
  background: rgba(14, 61, 74, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.35rem;
  font-size: 0.78rem;
}
.cert-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.cert-badge-panel {
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #f7fbfa 0%, #eef6f4 100%);
  border: 1px solid rgba(59, 191, 173, 0.55);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.cert-badge-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.cert-badge-controls-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal-dark);
  font-weight: 700;
}
.cert-badge-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.cert-badge-preview {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}
.cert-badge-preview img {
  max-width: 100%;
  height: auto;
  display: block;
}
.cert-badge-snippet-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.cert-badge-snippet-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.cert-badge-snippet-row textarea {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  resize: vertical;
}
.cert-badge-snippet-row .btn {
  align-self: flex-start;
}

/* -------------------------------------------------- Verify page */

.verify-hero {
  text-align: center;
  padding: 1rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.verify-hero h2 {
  margin: 0.5rem 0 0;
  font-size: 1.5rem;
  color: var(--navy);
}

/* -------------------------------------------------- Course viewer layout */

.viewer-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.viewer-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 1rem);
  max-height: calc(100vh - var(--topbar-h) - 2rem);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 1rem;
}

/* Collapsed/expanded shell — the toggle is mobile-only; on desktop the
   button is hidden and the body always shows. */
.viewer-sidebar-toggle { display: none; }
.viewer-sidebar-body { display: block; }

.viewer-course-title {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.01em;
}

.viewer-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;  /* prevent grid from forcing overflow */
}

/* -------------------------------------------------- Module / lesson tree */

.module-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.module-item {
  margin-bottom: 0.6rem;
}
.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
}
.module-header:hover { background: #edf0f3; }
.module-header .arrow {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 120ms ease;
}
.module-item.open .module-header .arrow { transform: rotate(90deg); }
.module-item.open .lesson-list          { display: block; }
.lesson-list {
  list-style: none;
  margin: 0.25rem 0 0 0;
  padding: 0;
  display: none;
}
.lesson-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.lesson-item:hover { background: var(--bg); }
.lesson-item.active {
  background: var(--teal-light);
  border-left-color: var(--teal);
  color: var(--navy);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(59, 191, 173, 0.35);
}
.lesson-item.active .lesson-icon { color: var(--teal-dark); }
.lesson-icon   {
  color: var(--teal-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}
.lesson-label  { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-duration { font-size: 0.72rem; color: var(--muted); }

.lesson-item.complete .lesson-icon { color: #34a06a; }
.lesson-item.complete .lesson-label { color: var(--muted); }
.lesson-item.complete::after {
  content: '\2713';                 /* ✓ */
  color: #34a06a;
  font-weight: 700;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

/* Mark-as-complete action row under the lesson info panel */
.lesson-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.lesson-complete-badge {
  color: #1f6a42;
  font-weight: 600;
  font-size: 0.9rem;
}

/* -------------------------------------------------- Video player */

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-container video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--teal);
  text-align: center;
}
.video-placeholder-glyph { font-size: 3rem; }

/* -------------------------------------------------- Lesson info + links */

.lesson-info h2 {
  margin: 0 0 0.35rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}
.lesson-info p { margin: 0.25rem 0; }
.link-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0 0;
}
.link-list li { padding: 0.2rem 0; }

/* -------------------------------------------------- Puzzle UI */

#puzzle-section h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
}
#puzzle-meta {
  margin: 0 0 1.25rem 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-dark);
}

/* All puzzle list containers strip default bullets/numbers. */
.puzzle-list,
.puzzle-sequence {
  list-style: none !important;
  margin: 0;
  padding: 0;
}

/* The shared card row used by matching, sequencing, drag-drop. */
.puzzle-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.6rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.puzzle-card:hover {
  border-color: var(--teal);
}

/* Up/down icon buttons (sequencing) — pinned on the left. */
.puzzle-card-actions {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.puzzle-icon-btn {
  width: 28px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-dark);
  background: var(--bg);
  color: var(--navy);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 80ms ease, border-color 80ms ease;
}
.puzzle-icon-btn:hover:not(:disabled) {
  background: var(--teal-light);
  border-color: var(--teal);
}
.puzzle-icon-btn:disabled { opacity: 0.3; cursor: default; }

/* Position badge / pair number */
.puzzle-card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Term cell (matching, drag_drop) */
.puzzle-card-term {
  flex: 0 0 auto;
  min-width: 9rem;
  font-weight: 600;
  color: var(--navy);
}
.puzzle-card-arrow {
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}

/* Body text (sequencing) */
.puzzle-card-body {
  flex: 1 1 auto;
  font-weight: 500;
  color: var(--text);
}

/* Custom select with teal accent on focus/hover */
.puzzle-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.puzzle-select:hover { border-color: var(--teal); }
.puzzle-select:focus {
  outline: none;
  border-color: var(--teal-dark);
  box-shadow: 0 0 0 3px rgba(59, 191, 173, 0.18);
}
.puzzle-select:disabled {
  opacity: 0.7;
  cursor: default;
  background: var(--bg);
}

/* Language selector (course overview card + viewer sidebar) */
.sidebar-lang { margin-bottom: 1rem; }
.lang-select  { display: block; width: 100%; }

/* Visually hidden but available to assistive tech (e.g. the language
   live-region announcer) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Fill-blank inline inputs in a contextual sentence panel */
.puzzle-fillblank {
  font-size: 1.05rem;
  line-height: 2;
  margin: 0;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.puzzle-blank {
  display: inline-block;
  min-width: 8rem;
  padding: 0.3rem 0.6rem;
  margin: 0 0.15rem;
  border: 1px solid var(--border-dark);
  border-bottom: 2px solid var(--teal-dark);
  background: var(--panel);
  font: inherit;
  color: var(--navy);
  font-weight: 600;
  border-radius: 4px 4px 0 0;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.puzzle-blank:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--teal-light);
}
.puzzle-blank:disabled { opacity: 0.85; }

/* Drag-drop target legend (chips) */
.puzzle-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 1rem 0;
  padding: 0.85rem 1rem;
  background: var(--bg);
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  align-items: center;
}
.puzzle-targets-label {
  width: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.puzzle-target-chip {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Logic puzzle: prompt, hints, free-form response */
.puzzle-prompt {
  margin: 0 0 1rem 0;
  padding: 1rem 1.25rem;
  background: var(--teal-light);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  line-height: 1.55;
  color: var(--navy);
}
.puzzle-hints {
  margin: 0 0 1rem 0;
  padding: 0.65rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.puzzle-hints summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
  font-size: 0.85rem;
}
.puzzle-hints[open] summary { margin-bottom: 0.5rem; }
.puzzle-hints ul { margin: 0; padding-left: 1.5rem; }
.puzzle-hints li { padding: 0.15rem 0; }
.puzzle-textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  background: var(--panel);
  resize: vertical;
  min-height: 8rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.puzzle-textarea:focus {
  outline: none;
  border-color: var(--teal-dark);
  box-shadow: 0 0 0 3px rgba(59, 191, 173, 0.18);
}

.quiz-question {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.quiz-question:last-of-type { border-bottom: 0; }
.quiz-question h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.quiz-option {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  margin-top: 0.35rem;
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease;
  background: var(--panel);
}
.quiz-option:hover     { background: var(--bg); }
.quiz-option.selected  { border-color: var(--navy); background: var(--bg); }
.quiz-option.correct   { border-color: #34a06a; background: #e5f5ec; }
.quiz-option.incorrect { border-color: var(--danger); background: var(--danger-bg); }

/* -------------------------------------------------- Alerts extras */

.alert-success {
  background: #e5f5ec;
  color: #1f6a42;
  border: 1px solid #b5dec7;
}
.alert-info {
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid #abe0d8;
}

/* -------------------------------------------------- Nav buttons */

.nav-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.nav-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.nav-hint[hidden] { display: none; }

.nav-hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* -------------------------------------------------- Modal dialog */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 61, 74, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: modal-fade 120ms ease;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 0 20px 60px rgba(14, 61, 74, 0.35);
  animation: modal-pop 140ms cubic-bezier(0.2, 0.8, 0.3, 1.05);
}
.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}
.modal-message {
  margin: 0 0 1.25rem;
  color: var(--text);
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* -------------------------------------------------- Responsive */

@media (max-width: 900px) {
  .viewer-layout  { grid-template-columns: 1fr; }
  .viewer-sidebar { position: static; max-height: none; padding: 0.5rem 0.75rem; }
  .course-landing   { grid-template-columns: 1fr; }
  .landing-sidebar  { position: static; }

  /* Mobile: sidebar becomes a collapsible drawer showing only the current item. */
  .viewer-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    background: transparent;
    border: 0;
    padding: 0.5rem 0;
    cursor: pointer;
    font: inherit;
    color: var(--navy);
    text-align: left;
  }
  .viewer-sidebar-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    overflow: hidden;
  }
  .viewer-sidebar-toggle-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
  }
  .viewer-sidebar-toggle-text strong {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .viewer-sidebar-toggle-caret {
    color: var(--muted);
    transition: transform 120ms ease;
  }
  .viewer-sidebar.collapsed .viewer-sidebar-toggle-caret { transform: rotate(-90deg); }
  .viewer-sidebar.collapsed .viewer-sidebar-body        { display: none; }
  .viewer-sidebar-body { padding-top: 0.5rem; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 1rem; }
  .brand-sub { display: none; }
  .user-info { display: none; }
  .page { padding: 1rem; }
  .pagefoot { flex-direction: column; gap: 0.25rem; text-align: center; }
}
