/* ============================================================
   main.css — Professional Development Course Platform
   Mobile-first, CSS Custom Properties, Grid + Flexbox
   ============================================================ */

/* ============================================================
   1. CUSTOM PROPERTIES (DESIGN TOKENS)
   ============================================================ */
:root {
  /* --- Colors --- */
  --color-navy:        #0f172a;
  --color-navy-800:    #1e293b;
  --color-navy-700:    #334155;
  --color-navy-600:    #475569;
  --color-navy-400:    #94a3b8;
  --color-navy-200:    #e2e8f0;
  --color-navy-100:    #f1f5f9;
  --color-navy-50:     #f8fafc;

  --color-teal:        #0d9488;
  --color-teal-700:    #0f766e;
  --color-teal-600:    #0d9488;
  --color-teal-400:    #2dd4bf;
  --color-teal-100:    #ccfbf1;
  --color-teal-50:     #f0fdfa;

  --color-white:       #ffffff;
  --color-black:       #000000;

  /* Semantic */
  --color-success:     #16a34a;
  --color-success-bg:  #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-error:       #dc2626;
  --color-error-bg:    #fef2f2;
  --color-error-border:#fecaca;

  --color-warning:     #d97706;
  --color-warning-bg:  #fffbeb;
  --color-warning-border: #fde68a;

  --color-info:        #0369a1;
  --color-info-bg:     #f0f9ff;
  --color-info-border: #bae6fd;

  /* Phase colors */
  --color-phase-learn: #3b82f6;
  --color-phase-apply: #f59e0b;
  --color-phase-test:  #10b981;

  /* Badge colors */
  --color-badge-done:    #16a34a;
  --color-badge-done-bg: #dcfce7;
  --color-badge-wip:     #d97706;
  --color-badge-wip-bg:  #fef3c7;
  --color-badge-pending: #64748b;
  --color-badge-pending-bg: #f1f5f9;

  /* --- Spacing scale --- */
  --space-1:  0.25rem;   /*  4px */
  --space-2:  0.5rem;    /*  8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* --- Typography --- */
  --font-sans:  'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;
  --leading-loose:  2;

  /* --- Layout --- */
  --container-max:  1100px;
  --header-height:  64px;
  --sidebar-width:  260px;

  /* --- Borders --- */
  --radius-sm:  0.25rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-full: 9999px;

  --border-color: var(--color-navy-200);

  /* --- Shadows --- */
  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* --- Transitions --- */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;
}

/* ============================================================
   2. CSS RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-navy-800);
  background-color: var(--color-navy-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-teal-700);
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--color-navy);
}

/* ============================================================
   3. ANIMATIONS & KEYFRAMES
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes progressFill {
  from { width: 0%; }
}

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.animate-fade-in  { animation: fadeIn  var(--transition-slow) ease both; }
.animate-slide-up { animation: slideUp var(--transition-slow) ease both; }
.animate-scale-in { animation: scaleIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 640px) {
  .container { padding-inline: var(--space-6); }
}

@media (min-width: 1024px) {
  .container { padding-inline: var(--space-8); }
}

.main-content {
  flex: 1;
  padding-block: var(--space-8);
}

@media (min-width: 768px) {
  .main-content { padding-block: var(--space-12); }
}

/* ============================================================
   5. SITE HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--color-navy);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 4px 12px 0 rgb(0 0 0 / 0.15);
  display: flex;
  align-items: center;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 100%;
}

/* --- Logo --- */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo__icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-teal), var(--color-teal-400));
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-white);
  box-shadow: 0 0 0 2px rgb(13 148 136 / 0.3);
}

.site-logo__text {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-white);
  letter-spacing: -0.02em;
}

.site-logo__text span {
  color: var(--color-teal-400);
}

/* --- Main Nav --- */
.main-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

@media (min-width: 768px) {
  .main-nav { display: flex; }
}

.main-nav__link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-navy-400);
  transition: color var(--transition-fast), background-color var(--transition-fast);
  white-space: nowrap;
}

.main-nav__link:hover,
.main-nav__link.is-active {
  color: var(--color-white);
  background-color: rgb(255 255 255 / 0.08);
}

.main-nav__link.is-active {
  color: var(--color-teal-400);
  background-color: rgb(13 148 136 / 0.15);
}

/* --- Header User Area --- */
.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
}

/* Mini progress bar in header */
.progress-mini {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

@media (min-width: 640px) {
  .progress-mini { display: flex; }
}

.progress-mini__label {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
  white-space: nowrap;
}

.progress-mini__track {
  width: 100px;
  height: 4px;
  background-color: rgb(255 255 255 / 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-mini__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-teal), var(--color-teal-400));
  border-radius: var(--radius-full);
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  animation: progressFill 800ms ease both;
}

/* --- User Menu / Dropdown --- */
.user-menu {
  position: relative;
}

.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-navy-400);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.user-menu__trigger:hover {
  background-color: rgb(255 255 255 / 0.08);
  color: var(--color-white);
}

.user-menu__avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-teal-700), var(--color-teal-400));
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-white);
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-menu__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-white);
  display: none;
}

@media (min-width: 640px) {
  .user-menu__name { display: block; }
}

.user-menu__chevron {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.user-menu.is-open .user-menu__chevron {
  transform: rotate(180deg);
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 200px;
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-1);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
}

.user-menu.is-open .user-menu__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu__dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-navy-700);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.user-menu__dropdown-item:hover {
  background-color: var(--color-navy-100);
  color: var(--color-navy);
}

.user-menu__dropdown-item--danger {
  color: var(--color-error);
}

.user-menu__dropdown-item--danger:hover {
  background-color: var(--color-error-bg);
}

.user-menu__dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: var(--space-1);
}

/* --- Hamburger (mobile) --- */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: var(--space-2);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.hamburger:hover { background-color: rgb(255 255 255 / 0.08); }

@media (min-width: 768px) {
  .hamburger { display: none; }
}

.hamburger__line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--color-navy-400);
  border-radius: 2px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* Mobile nav drawer */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background-color: var(--color-navy);
  padding: calc(var(--header-height) + var(--space-4)) var(--space-4) var(--space-4);
  flex-direction: column;
  gap: var(--space-1);
}

.mobile-nav.is-open { display: flex; }

.mobile-nav__link {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--color-navy-400);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.mobile-nav__link:hover,
.mobile-nav__link.is-active {
  background-color: rgb(255 255 255 / 0.08);
  color: var(--color-white);
}

/* ============================================================
   6. SITE FOOTER
   ============================================================ */
.site-footer {
  background-color: var(--color-navy);
  color: var(--color-navy-400);
  padding-block: var(--space-8);
  font-size: var(--text-sm);
  margin-top: auto;
}

.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
  text-align: center;
}

@media (min-width: 640px) {
  .site-footer .container {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

.site-footer__links {
  display: flex;
  gap: var(--space-4);
}

.site-footer__links a {
  color: var(--color-navy-400);
  transition: color var(--transition-fast);
}

.site-footer__links a:hover {
  color: var(--color-teal-400);
}

/* ============================================================
   7. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background-color: var(--color-teal);
  color: var(--color-white);
  border-color: var(--color-teal);
}

.btn-primary:hover {
  background-color: var(--color-teal-700);
  border-color: var(--color-teal-700);
  color: var(--color-white);
  box-shadow: 0 0 0 3px rgb(13 148 136 / 0.2);
}

/* Secondary */
.btn-secondary {
  background-color: var(--color-white);
  color: var(--color-navy-700);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--color-navy-100);
  border-color: var(--color-navy-400);
  color: var(--color-navy);
}

/* Danger */
.btn-danger {
  background-color: var(--color-error);
  color: var(--color-white);
  border-color: var(--color-error);
}

.btn-danger:hover {
  background-color: #b91c1c;
  border-color: #b91c1c;
  color: var(--color-white);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.2);
}

/* Ghost */
.btn-ghost {
  background-color: transparent;
  color: var(--color-navy-600);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--color-navy-100);
  color: var(--color-navy);
}

/* Sizes */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

/* ============================================================
   8. CARDS
   ============================================================ */
.card {
  background-color: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background-color: var(--color-navy-50);
}

.card-header__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background-color: var(--color-navy-50);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================================
   9. FORMS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-navy-700);
}

.form-label--required::after {
  content: ' *';
  color: var(--color-error);
}

.form-control {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-navy-800);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  line-height: var(--leading-normal);
}

.form-control::placeholder {
  color: var(--color-navy-400);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgb(13 148 136 / 0.15);
}

.form-control:invalid,
.form-control.is-invalid {
  border-color: var(--color-error);
}

.form-control:invalid:focus,
.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
  cursor: pointer;
  padding-right: var(--space-8);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
}

/* ============================================================
   10. ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  animation: slideUp var(--transition-normal) ease both;
  margin-bottom: var(--space-4);
}

.alert__icon { flex-shrink: 0; font-size: var(--text-base); }
.alert__body { flex: 1; }
.alert__title { font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.alert__close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0;
  transition: opacity var(--transition-fast);
}
.alert__close:hover { opacity: 1; }

.alert-success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: #14532d;
}

.alert-error {
  background-color: var(--color-error-bg);
  border-color: var(--color-error-border);
  color: #7f1d1d;
}

.alert-warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: #78350f;
}

.alert-info {
  background-color: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: #0c4a6e;
}

/* Flash message container */
.flash-messages {
  position: fixed;
  top: calc(var(--header-height) + var(--space-3));
  right: var(--space-4);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
  width: calc(100% - var(--space-8));
}

/* ============================================================
   11. BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-done {
  background-color: var(--color-badge-done-bg);
  color: var(--color-badge-done);
}

.badge-wip {
  background-color: var(--color-badge-wip-bg);
  color: var(--color-badge-wip);
}

.badge-pending {
  background-color: var(--color-badge-pending-bg);
  color: var(--color-badge-pending);
}

/* ============================================================
   12. PROGRESS BAR
   ============================================================ */
.progress-bar {
  width: 100%;
  background-color: var(--color-navy-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar--sm { height: 4px; }
.progress-bar--md { height: 8px; }
.progress-bar--lg { height: 12px; }

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-teal), var(--color-teal-400));
  border-radius: var(--radius-full);
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  animation: progressFill 800ms ease both;
}

.progress-bar__fill--success {
  background: linear-gradient(90deg, var(--color-success), #22c55e);
}

.progress-bar__fill--warning {
  background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

/* ============================================================
   13. MODULE GRID & MODULE CARDS
   ============================================================ */
.module-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-block: var(--space-6);
}

@media (min-width: 600px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Module card */
.module-card {
  background-color: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.module-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* Phase strip — three colored bars at top of card */
.module-card__phases {
  display: flex;
  height: 6px;
}

.module-card__phase {
  flex: 1;
}

.module-card__phase--learn { background-color: var(--color-phase-learn); }
.module-card__phase--apply { background-color: var(--color-phase-apply); }
.module-card__phase--test  { background-color: var(--color-phase-test);  }

.module-card__phase--done  { opacity: 1; }
.module-card__phase--wip   { opacity: 0.6; }
.module-card__phase--pending { opacity: 0.2; }

.module-card__body {
  padding: var(--space-5);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.module-card__number {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-teal);
}

.module-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  line-height: var(--leading-tight);
}

.module-card__description {
  font-size: var(--text-sm);
  color: var(--color-navy-600);
  line-height: var(--leading-relaxed);
  flex: 1;
}

.module-card__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-navy-50);
}

/* ============================================================
   14. PHASE TABS (Learn / Apply / Test)
   ============================================================ */
.phase-tabs {
  display: flex;
  gap: var(--space-1);
  background-color: var(--color-navy-100);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  margin-bottom: var(--space-6);
  width: fit-content;
}

.phase-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-navy-600);
  cursor: pointer;
  border: none;
  background: none;
  transition: background-color var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.phase-tab:hover {
  color: var(--color-navy);
}

.phase-tab--learn.is-active {
  background-color: var(--color-white);
  color: var(--color-phase-learn);
  box-shadow: var(--shadow-sm);
}

.phase-tab--apply.is-active {
  background-color: var(--color-white);
  color: var(--color-phase-apply);
  box-shadow: var(--shadow-sm);
}

.phase-tab--test.is-active {
  background-color: var(--color-white);
  color: var(--color-phase-test);
  box-shadow: var(--shadow-sm);
}

.phase-tab__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.phase-tab--learn .phase-tab__dot { background-color: var(--color-phase-learn); }
.phase-tab--apply .phase-tab__dot { background-color: var(--color-phase-apply); }
.phase-tab--test  .phase-tab__dot { background-color: var(--color-phase-test);  }

/* ============================================================
   15. LESSON CONTENT (PROSE)
   ============================================================ */
.lesson-content {
  max-width: 72ch;
  color: var(--color-navy-700);
  line-height: var(--leading-relaxed);
}

.lesson-content h1,
.lesson-content h2,
.lesson-content h3,
.lesson-content h4 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  color: var(--color-navy);
}

.lesson-content h1 { font-size: var(--text-3xl); }
.lesson-content h2 { font-size: var(--text-2xl); }
.lesson-content h3 { font-size: var(--text-xl);  }
.lesson-content h4 { font-size: var(--text-lg);  }

.lesson-content p { margin-bottom: var(--space-4); }

.lesson-content ul,
.lesson-content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.lesson-content ul { list-style: disc; }
.lesson-content ol { list-style: decimal; }
.lesson-content li { margin-bottom: var(--space-2); }

.lesson-content strong { font-weight: var(--weight-semibold); color: var(--color-navy); }
.lesson-content em     { font-style: italic; }

.lesson-content a {
  color: var(--color-teal);
  text-decoration: underline;
  text-decoration-color: rgb(13 148 136 / 0.4);
  text-underline-offset: 2px;
}

.lesson-content a:hover {
  color: var(--color-teal-700);
  text-decoration-color: var(--color-teal-700);
}

.lesson-content blockquote {
  border-left: 3px solid var(--color-teal);
  padding-left: var(--space-4);
  margin-left: 0;
  margin-bottom: var(--space-4);
  color: var(--color-navy-600);
  font-style: italic;
}

.lesson-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-navy-100);
  color: var(--color-teal-700);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
}

.lesson-content pre {
  background-color: var(--color-navy);
  color: #e2e8f0;
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  position: relative;
}

.lesson-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}

.lesson-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin-block: var(--space-8);
}

/* Code copy button */
.code-block {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  background-color: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.15);
  color: var(--color-navy-400);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.code-copy-btn:hover {
  background-color: rgb(255 255 255 / 0.2);
  color: var(--color-white);
}

.code-copy-btn.is-copied {
  color: var(--color-teal-400);
  border-color: var(--color-teal-400);
}

/* ============================================================
   16. PROMPT EDITOR (dark terminal-style)
   ============================================================ */
.prompt-editor {
  background-color: var(--color-navy);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-navy-700);
  box-shadow: var(--shadow-lg);
}

.prompt-editor__titlebar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-navy-800);
  border-bottom: 1px solid var(--color-navy-700);
}

.prompt-editor__dots {
  display: flex;
  gap: 6px;
}

.prompt-editor__dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
}

.prompt-editor__dot--red    { background-color: #ef4444; }
.prompt-editor__dot--yellow { background-color: #eab308; }
.prompt-editor__dot--green  { background-color: #22c55e; }

.prompt-editor__label {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
  font-family: var(--font-mono);
  margin-left: auto;
}

.prompt-editor__textarea {
  width: 100%;
  min-height: 160px;
  padding: var(--space-4) var(--space-5);
  background-color: var(--color-navy);
  border: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #e2e8f0;
  line-height: var(--leading-loose);
  caret-color: var(--color-teal-400);
}

.prompt-editor__textarea::placeholder {
  color: var(--color-navy-600);
}

.prompt-editor__textarea:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--color-teal-700);
}

.prompt-editor__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-navy-800);
  border-top: 1px solid var(--color-navy-700);
  gap: var(--space-3);
}

.prompt-editor__token-count {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
  font-family: var(--font-mono);
}

/* ============================================================
   17. AI OUTPUT BOX
   ============================================================ */
.ai-output {
  background-color: var(--color-navy);
  border: 1px solid var(--color-navy-700);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #a5f3fc;          /* cyan-ish for output text */
  line-height: var(--leading-relaxed);
  min-height: 120px;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-output--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-navy-600);
  font-style: italic;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

/* Syntax-style coloring classes used by JS renderer */
.ai-output .tok-key    { color: #7dd3fc; }   /* keywords: blue */
.ai-output .tok-str    { color: #86efac; }   /* strings: green */
.ai-output .tok-num    { color: #fdba74; }   /* numbers: orange */
.ai-output .tok-cmt    { color: #6b7280; font-style: italic; }
.ai-output .tok-tag    { color: #f9a8d4; }   /* html tags: pink */
.ai-output .tok-attr   { color: #fde047; }   /* attributes: yellow */

/* Blinking cursor during streaming */
.ai-output__cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background-color: var(--color-teal-400);
  animation: pulse 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

/* ============================================================
   18. TEST RUBRIC TABLE
   ============================================================ */
.test-rubric {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.test-rubric thead {
  background-color: var(--color-navy-800);
  color: var(--color-white);
}

.test-rubric thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.test-rubric tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition-fast);
}

.test-rubric tbody tr:hover {
  background-color: var(--color-navy-50);
}

.test-rubric tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-navy-700);
  vertical-align: top;
}

.test-rubric__criterion {
  font-weight: var(--weight-medium);
  color: var(--color-navy);
}

.test-rubric__score {
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  white-space: nowrap;
}

.test-rubric__score--high   { color: var(--color-success); }
.test-rubric__score--medium { color: var(--color-warning); }
.test-rubric__score--low    { color: var(--color-error);   }

.test-rubric tfoot {
  background-color: var(--color-navy-100);
  font-weight: var(--weight-semibold);
}

.test-rubric tfoot td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-navy);
}

/* ============================================================
   19. SCORE DISPLAY (circular badge)
   ============================================================ */
.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.score-display__circle {
  position: relative;
  width: 120px;
  height: 120px;
}

.score-display__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-display__track {
  fill: none;
  stroke: var(--color-navy-200);
  stroke-width: 8;
}

.score-display__fill {
  fill: none;
  stroke: var(--color-teal);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-display__fill--high   { stroke: var(--color-success); }
.score-display__fill--medium { stroke: var(--color-warning); }
.score-display__fill--low    { stroke: var(--color-error);   }

.score-display__number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
}

.score-display__label {
  font-size: var(--text-sm);
  color: var(--color-navy-600);
  font-weight: var(--weight-medium);
}

.score-display__sublabel {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
}

/* ============================================================
   20. CERTIFICATE PREVIEW
   ============================================================ */
.certificate-preview {
  background: linear-gradient(135deg, #fefce8 0%, #fffbeb 50%, #fef9c3 100%);
  border: 3px solid #d97706;
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-12);
  text-align: center;
  position: relative;
  box-shadow: 0 0 0 6px #fef3c7, var(--shadow-xl);
  max-width: 640px;
  margin-inline: auto;
  animation: scaleIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.certificate-preview::before,
.certificate-preview::after {
  content: '';
  position: absolute;
  inset: var(--space-3);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: calc(var(--radius-xl) - 6px);
  pointer-events: none;
}

.certificate-preview__seal {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--color-teal), var(--color-teal-700));
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  margin-inline: auto;
  margin-bottom: var(--space-4);
  font-size: 2rem;
  box-shadow: 0 0 0 4px #fef3c7, 0 0 0 6px var(--color-teal-700);
}

.certificate-preview__headline {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-warning);
  margin-bottom: var(--space-2);
}

.certificate-preview__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-4);
  font-family: Georgia, 'Times New Roman', serif;
}

.certificate-preview__recipient {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-teal-700);
  margin-bottom: var(--space-3);
  font-style: italic;
}

.certificate-preview__body {
  font-size: var(--text-sm);
  color: var(--color-navy-600);
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

.certificate-preview__course {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  margin-bottom: var(--space-8);
}

.certificate-preview__footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(217, 119, 6, 0.3);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-navy-400);
}

/* ============================================================
   21. ADMIN TABLE STYLES
   ============================================================ */
.admin-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.admin-table thead {
  background-color: var(--color-navy-800);
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-navy-400);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.admin-table thead th:hover { color: var(--color-white); }

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--color-white);
  transition: background-color var(--transition-fast);
}

.admin-table tbody tr:last-child { border-bottom: none; }

.admin-table tbody tr:hover {
  background-color: var(--color-navy-50);
}

.admin-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-navy-700);
  vertical-align: middle;
}

.admin-table__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* Admin stats grid */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

@media (min-width: 768px) {
  .admin-stats { grid-template-columns: repeat(4, 1fr); }
}

.admin-stat {
  background-color: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
}

.admin-stat__number {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.admin-stat__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-navy-400);
  font-weight: var(--weight-medium);
}

/* ============================================================
   22. LOADING SPINNER
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

.spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }
.spinner--xl { width: 48px; height: 48px; border-width: 4px; }

.spinner--teal  { color: var(--color-teal); }
.spinner--white { color: var(--color-white); }

/* Full-screen loader overlay */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  background-color: rgb(15 23 42 / 0.6);
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
}

/* Loading state for output areas */
.output-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--color-navy-400);
  font-size: var(--text-sm);
}

/* ============================================================
   23. APPLY PHASE EDITOR
   ============================================================ */
.apply-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .apply-editor { grid-template-columns: 1fr 1fr; }
}

.apply-editor__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.apply-editor__preview-wrapper {
  position: relative;
  background-color: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.apply-editor__preview-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-navy-100);
  border-bottom: 1px solid var(--border-color);
}

.apply-editor__preview-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-navy-600);
}

.apply-editor__iframe {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 360px;
}

/* ============================================================
   24. MISCELLANEOUS UTILITY CLASSES
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-navy-400); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }
.gap-4       { gap: var(--space-4); }
.gap-6       { gap: var(--space-6); }

.mt-4        { margin-top: var(--space-4); }
.mt-6        { margin-top: var(--space-6); }
.mt-8        { margin-top: var(--space-8); }
.mb-4        { margin-bottom: var(--space-4); }
.mb-6        { margin-bottom: var(--space-6); }

.w-full      { width: 100%; }
.hidden      { display: none !important; }
.block       { display: block; }

/* Page title + breadcrumb area */
.page-header {
  margin-bottom: var(--space-8);
}

.page-header__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-navy-400);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.page-header__breadcrumb-sep {
  color: var(--color-navy-200);
}

.page-header__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-2);
}

.page-header__subtitle {
  font-size: var(--text-base);
  color: var(--color-navy-600);
  max-width: 60ch;
}

/* Divider */
.divider {
  height: 1px;
  background-color: var(--border-color);
  margin-block: var(--space-6);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-4);
  color: var(--color-navy-400);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-navy-600);
  margin-bottom: var(--space-2);
}

.empty-state__body {
  font-size: var(--text-sm);
  max-width: 40ch;
  margin-inline: auto;
  margin-bottom: var(--space-6);
}

/* ============================================================
   25. LOGO IMAGE FIX
   ============================================================ */
.logo-icon {
  display: inline-block;
  vertical-align: middle;
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ============================================================
   26. FOOTER COPY LINE
   ============================================================ */
.footer-copy {
  font-size: var(--text-xs);
  color: var(--color-navy-400);
  margin-top: var(--space-3);
  letter-spacing: 0.03em;
}

/* ============================================================
   27. PHASE SECTION VISUAL DISTINCTION
   ============================================================ */

/* Module-page container spacing */
.module-page.container {
  padding-top: var(--space-8);
  padding-bottom: var(--space-12);
}

/* Module header card */
.module-header {
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--color-teal);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.module-header__number {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-teal);
  margin-bottom: var(--space-1);
}

.module-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-1);
}

.module-header__desc {
  font-size: var(--text-base);
  color: var(--color-navy-600);
}

/* Phase section wrappers — each phase gets a tinted background */
.phase-section {
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  margin-top: var(--space-4);
  border: 1px solid transparent;
}

.phase-section--learn {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  border-left: 5px solid var(--color-phase-learn);
}

.phase-section--apply {
  background-color: #fffbeb;
  border-color: #fde68a;
  border-left: 5px solid var(--color-phase-apply);
}

.phase-section--test {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  border-left: 5px solid var(--color-phase-test);
}

/* Lesson content typographic hierarchy */
.lesson-content {
  max-width: none; /* override 72ch — let the container handle width */
}

.lesson-content h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  border-left: 4px solid var(--color-teal);
  padding-left: var(--space-4);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
}

.lesson-content h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  border-left: 3px solid var(--color-navy-200);
  padding-left: var(--space-3);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.lesson-content h4 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.lesson-content p,
.lesson-content li {
  color: var(--color-navy-700);
  line-height: var(--leading-relaxed);
}

.lesson-content ul,
.lesson-content ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.lesson-content li {
  margin-bottom: var(--space-2);
}

/* Apply phase instruction box */
.apply-instructions {
  background-color: var(--color-white);
  border: 1px solid #fde68a;
  border-left: 4px solid var(--color-phase-apply);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  color: var(--color-navy-700);
}

/* Prompt editor layer labels */
.prompt-editor__field {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-navy-700);
}

.prompt-editor__field:last-child {
  border-bottom: none;
}

.prompt-editor__field label {
  display: block;
  font-size: var(--text-sm);
  color: #94a3b8;
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
}

.prompt-editor__field label strong {
  color: var(--color-white);
}

.prompt-editor__field small {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-navy-500);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
}

/* Layer colour accents on the left of each field */
.prompt-editor__field:nth-child(1) {
  border-left: 3px solid var(--color-phase-learn);
}

.prompt-editor__field:nth-child(2) {
  border-left: 3px solid var(--color-phase-apply);
}

.prompt-editor__field:nth-child(3) {
  border-left: 3px solid var(--color-phase-test);
}

/* Test task description box */
.test-task-description {
  background-color: var(--color-white);
  border: 1px solid #a7f3d0;
  border-left: 4px solid var(--color-phase-test);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
}

.test-task-description h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-phase-test);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.test-task-description p,
.test-task-description li {
  color: var(--color-navy-700);
  line-height: var(--leading-relaxed);
}

.test-task-description ol,
.test-task-description ul {
  padding-left: var(--space-5);
}

.test-task-description li {
  margin-bottom: var(--space-1);
}

/* Apply header */
.apply-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-6);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.apply-header h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  border-left: 4px solid var(--color-phase-apply);
  padding-left: var(--space-4);
}

.ai-rate-info {
  font-size: var(--text-sm);
  color: var(--color-navy-500);
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-4);
}

/* ============================================================
   28. FULL-WIDTH INPUTS, TEXTAREAS & PREVIEW FRAME
   ============================================================ */

/*
 * Base rule: every textarea inside a phase section or prompt editor
 * must fill its container. Overrides browser "cols" default width.
 */
.phase-section textarea,
.prompt-editor textarea,
.output-area textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: block;
}

/* Prompt editor textareas — dark terminal style */
.prompt-editor__field textarea {
  width: 100%;
  display: block;
  min-height: 180px;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-navy);
  border: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #e2e8f0;
  line-height: var(--leading-loose);
  caret-color: var(--color-teal-400);
  box-sizing: border-box;
}

.prompt-editor__field textarea::placeholder {
  color: var(--color-navy-500);
}

.prompt-editor__field textarea:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--color-teal-700);
}

/* The vocabulary dataset textarea is taller */
.prompt-editor__field:nth-child(2) textarea {
  min-height: 240px;
}

/* Feature spec textarea taller still */
.prompt-editor__field:nth-child(3) textarea {
  min-height: 300px;
}

/* Output area layout */
.output-area {
  width: 100%;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-top: var(--space-6);
  background: var(--color-white);
}

.output-tabs {
  display: flex;
  gap: 0;
  background-color: var(--color-navy-100);
  border-bottom: 2px solid var(--border-color);
}

.output-tab {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-navy-500);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.output-tab:hover {
  color: var(--color-navy);
}

.output-tab--active {
  color: var(--color-navy);
  border-bottom-color: var(--color-teal);
}

.output-panel { display: none; }
.output-panel--active { display: block; }

/* Raw HTML textarea — full width, tall, monospace */
.raw-output {
  width: 100%;
  display: block;
  min-height: 440px;
  padding: var(--space-5);
  background-color: var(--color-navy);
  border: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #a5f3fc;
  line-height: var(--leading-relaxed);
  box-sizing: border-box;
}

.raw-output:focus {
  outline: none;
}

/* Preview iframe — full width, tall */
.preview-frame {
  width: 100%;
  height: 640px;
  border: none;
  display: block;
  background: var(--color-white);
}

/* Test submission textarea — full width */
.test-submission-area {
  margin-bottom: var(--space-4);
}

.test-submission-area textarea,
#testSubmission {
  width: 100%;
  display: block;
  min-height: 340px;
  padding: var(--space-5);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-navy);
  line-height: var(--leading-relaxed);
  resize: vertical;
  background: var(--color-white);
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.test-submission-area textarea:focus,
#testSubmission:focus {
  outline: none;
  border-color: var(--color-phase-test);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

/* Post-generation action bar */
.apply-post-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--color-navy-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

/* Generate / Submit action bars — full-width strip */
.apply-actions,
.test-actions {
  width: 100%;
  display: flex;
  margin-top: var(--space-5);
}

.apply-actions .btn,
.test-actions .btn {
  width: 100%;
  justify-content: center;
  padding-block: var(--space-4);
  font-size: var(--text-base);
}

/* Phase action bar at bottom of learn */
.phase-actions {
  margin-top: var(--space-8);
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   29. MEDIA PLACEHOLDERS (module learn sections)
   ============================================================ */
.media-assets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

@media (min-width: 640px) {
  .media-assets {
    grid-template-columns: repeat(4, 1fr);
  }
}

.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px dashed;
  text-align: center;
  cursor: default;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  min-height: 110px;
  background: rgb(255 255 255 / 0.6);
  user-select: none;
}

.media-placeholder:hover {
  background: var(--color-teal-50, #f0fdfa);
  border-color: var(--color-teal) !important;
  transform: translateY(-2px);
}

.media-placeholder--image {
  border-color: #93c5fd;
  color: #3b82f6;
}

.media-placeholder--video {
  border-color: #fca5a5;
  color: #ef4444;
}

.media-placeholder--pdf {
  border-color: #fcd34d;
  color: #d97706;
}

.media-placeholder--ppt {
  border-color: #86efac;
  color: #16a34a;
}

.media-placeholder__icon {
  font-size: 1.75rem;
  line-height: 1;
}

.media-placeholder__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: inherit;
}

.media-placeholder__hint {
  font-size: 0.68rem;
  color: var(--color-navy-400);
  max-width: 14ch;
  line-height: 1.3;
}

/* ============================================================
   30. BOOKSHELF COURSE CATALOG
   ============================================================ */
.bookshelf-page {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  min-height: 100vh;
}

.bookshelf-hero {
  text-align: center;
  padding: var(--space-16) var(--space-4) var(--space-10);
}

.bookshelf-hero__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-teal);
  margin-bottom: var(--space-3);
}

.bookshelf-hero__title {
  font-size: var(--text-4xl, 2.5rem);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-4);
}

.bookshelf-hero__sub {
  font-size: var(--text-lg);
  color: var(--color-navy-600);
  max-width: 52ch;
  margin-inline: auto;
}

/* The shelf container */
.bookshelf-wrap {
  max-width: 1100px;
  margin-inline: auto;
  padding: 0 var(--space-6) var(--space-16);
}

.bookshelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: 0 var(--space-4) 0;
  padding-bottom: 18px; /* shelf plank height */
  flex-wrap: wrap;
  justify-content: center;
}

/* Wooden shelf plank */
.bookshelf::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18px;
  background: linear-gradient(180deg, #b45309 0%, #92400e 60%, #78350f 100%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* Shelf shadow strip above the plank */
.bookshelf::before {
  content: '';
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.12) 100%);
  z-index: 1;
}

/* Individual book wrapper — creates hover lift + popup context */
.book-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

/* Book spine */
.book-spine {
  width: 56px;
  height: 210px;
  border-radius: 3px 8px 8px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset -3px 0 6px rgba(0,0,0,0.2), 2px 4px 8px rgba(0,0,0,0.25);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
  transform-origin: bottom center;
}

.book-item:hover .book-spine,
.book-item:focus-within .book-spine {
  transform: translateY(-52px) scale(1.06);
}

/* Spine title — rotated vertical text */
.book-spine__title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.72rem;
  font-weight: var(--weight-semibold);
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  letter-spacing: 0.04em;
  line-height: 1.3;
  padding: var(--space-3) 0;
  max-height: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spine decorative left edge (binding) */
.book-spine::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: rgba(0,0,0,0.18);
  border-radius: 3px 0 0 3px;
}

/* Popup cover card — hidden by default */
.book-cover {
  position: absolute;
  bottom: calc(100% + 16px);
  left: 50%;
  transform: translateX(-50%) scale(0.88) translateY(12px);
  transform-origin: bottom center;
  width: 220px;
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 8px 24px rgba(0,0,0,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
  overflow: hidden;
}

.book-item:hover .book-cover,
.book-item:focus-within .book-cover {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1) translateY(0);
}

.book-cover__thumbnail {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--color-navy-800) 0%, var(--color-navy) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255,255,255,0.25);
}

.book-cover__thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover__body {
  padding: var(--space-4);
}

.book-cover__badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.book-cover__badge {
  font-size: 0.65rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-teal-50, #f0fdfa);
  color: var(--color-teal-700, #0f766e);
}

.book-cover__title {
  font-size: 0.82rem;
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-2);
  line-height: 1.35;
}

.book-cover__desc {
  font-size: 0.72rem;
  color: var(--color-navy-500);
  line-height: 1.45;
  margin-bottom: var(--space-3);
}

.book-cover__cta {
  display: block;
  width: 100%;
  text-align: center;
  padding: var(--space-2) var(--space-3);
  background: var(--color-teal);
  color: var(--color-white);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: background-color var(--transition-fast);
}

.book-cover__cta:hover {
  background: var(--color-teal-700);
  color: var(--color-white);
}

/* Coming-soon books */
.book-item--coming-soon .book-spine {
  opacity: 0.55;
  filter: grayscale(0.4);
  cursor: not-allowed;
}

.book-item--coming-soon .book-cover {
  display: none;
}

.book-item--coming-soon:hover .book-spine {
  transform: translateY(-14px) scale(1.02);
}

.book-spine__tag {
  position: absolute;
  top: 10px;
  right: -4px;
  background: var(--color-warning);
  color: var(--color-white);
  font-size: 0.6rem;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  letter-spacing: 0.06em;
  writing-mode: horizontal-tb;
  transform: none;
}

/* Responsive: smaller books on mobile */
@media (max-width: 480px) {
  .book-spine {
    width: 44px;
    height: 170px;
  }
  .book-cover {
    width: 190px;
  }
}

/* ============================================================
   31. DATA TABLE — generic reusable table
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.data-table thead {
  background: var(--color-navy-800, #1e3a5f);
  color: #fff;
}

.data-table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--color-navy-100, #e8eff9);
  transition: background-color 0.15s;
}

.data-table tbody tr:nth-child(even) {
  background-color: var(--color-navy-50, #f5f8ff);
}

.data-table tbody tr:hover {
  background-color: var(--color-teal-50, #f0fdfa);
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  vertical-align: top;
  color: var(--color-navy-700, #334155);
  line-height: 1.55;
}

.data-table tfoot {
  background-color: var(--color-navy-100, #e8eff9);
  font-weight: var(--weight-semibold);
}

.data-table tfoot td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-navy);
  border-top: 2px solid var(--color-navy-200, #c8d9f0);
}

/* ============================================================
   32. TEST RESULTS AREA
   ============================================================ */

/* Outer wrapper card */
.test-results {
  margin-top: var(--space-8);
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-navy-150, #d4e5f9);
  border-top: 4px solid var(--color-phase-test, #10b981);
  box-shadow: 0 4px 20px rgba(16,185,129,0.10);
  padding: var(--space-8);
  animation: fadeInUp 0.4s ease both;
}

/* "Grading Results" heading */
.test-results > h3:first-of-type {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-navy);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-phase-test, #10b981);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.test-results > h3:first-of-type::before {
  content: '📊';
  font-size: 1.25rem;
}

/* Rubric container */
.rubric-container {
  margin-bottom: var(--space-6);
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

/* Rubric table overrides (built by inline JS) */
.rubric-table thead {
  background: linear-gradient(90deg, var(--color-phase-test, #10b981) 0%, #059669 100%);
}

.rubric-table tfoot {
  background: #ecfdf5;
}

.rubric-table tfoot td {
  border-top: 2px solid #6ee7b7;
  color: #065f46;
}

/* Score display wrapper */
.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* The simple text score (generated by inline PHP JS) */
.score-value {
  display: inline-block;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #6ee7b7;
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-xl);
  color: #064e3b;
  text-align: center;
  box-shadow: 0 2px 8px rgba(16,185,129,0.15);
}

.score-value strong {
  font-size: var(--text-2xl);
  color: #059669;
  margin: 0 var(--space-1);
}

/* Overall feedback box */
.overall-feedback {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-left: 4px solid var(--color-phase-learn, #3b82f6);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
  color: #1e3a5f;
  font-size: var(--text-sm);
  line-height: 1.7;
  position: relative;
}

.overall-feedback::before {
  content: '💬 Overall Feedback';
  display: block;
  font-weight: var(--weight-bold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-phase-learn, #3b82f6);
  margin-bottom: var(--space-2);
}

.overall-feedback p {
  margin: 0;
}

/* Passed / completion banner */
.passed-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 60%, #a7f3d0 100%);
  border: 2px solid #34d399;
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  box-shadow: 0 4px 20px rgba(52,211,153,0.20);
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
  overflow: hidden;
}

.passed-banner::before {
  content: '🎉';
  display: block;
  font-size: 2.5rem;
  margin-bottom: var(--space-3);
  animation: bounce 0.6s 0.3s ease both;
}

.passed-banner h3 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: #064e3b;
  margin-bottom: var(--space-3);
}

.passed-banner p {
  color: #065f46;
  margin-bottom: var(--space-5);
  font-size: var(--text-base);
}

/* ============================================================
   33. ATTEMPT HISTORY
   ============================================================ */
.attempt-history {
  margin-top: var(--space-8);
  border-top: 1px solid var(--color-navy-100, #e8eff9);
  padding-top: var(--space-6);
}

.attempt-history__toggle {
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-navy-600);
}

.attempt-history__list {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Bounce keyframe (bonus animation) */
@keyframes bounce {
  0%   { transform: translateY(-14px); opacity: 0; }
  60%  { transform: translateY(4px); opacity: 1; }
  80%  { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}
