:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #5d6678;
  --paper: #f7f6f0;
  --panel: #ffffff;
  --line: #d7dce5;
  --navy: #152e55;
  --blue: #1f5d99;
  --red: #b43a35;
  --gold: #bd8b2f;
  --green: #3f6f5f;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 54px);
  background: rgba(247, 246, 240, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-primary {
  display: block;
  width: clamp(128px, 18vw, 190px);
  height: auto;
  max-height: 52px;
  object-fit: contain;
}

.auth-brand-primary {
  display: block;
  width: min(230px, 100%);
  height: auto;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.legion-emblem {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.12);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.topnav a,
.topnav button,
.primary-action,
.secondary-action,
.lesson-actions button,
.auth-card button,
.stacked-form button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  background: var(--panel);
  cursor: pointer;
}

.topnav button {
  color: var(--red);
}

.inline-form {
  margin: 0;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(21, 46, 85, 0.1), transparent 38%),
    var(--paper);
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 18px 0 8px;
  font-size: 34px;
  line-height: 1.05;
}

.auth-card p {
  color: #374151;
  line-height: 1.55;
}

.auth-card form,
.stacked-form {
  display: grid;
  gap: 14px;
}

.auth-card label,
.stacked-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-card input,
.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-transform: none;
  background: #fff;
}

.stacked-form textarea {
  resize: vertical;
}

.auth-card button,
.stacked-form button {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.auth-card a {
  display: inline-block;
  margin-top: 16px;
  color: var(--blue);
}

.invite-login-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.invite-login-panel summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.invite-login-panel form {
  margin-top: 14px;
}

.form-error,
.form-success {
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.form-error {
  color: var(--red);
  background: #fff1f0;
  border: 1px solid rgba(180, 58, 53, 0.24);
}

.form-success {
  color: var(--green);
  background: #eff8f4;
  border: 1px solid rgba(63, 111, 95, 0.24);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.78fr);
  gap: clamp(24px, 6vw, 76px);
  align-items: center;
  min-height: 520px;
  padding: clamp(28px, 5vw, 54px) clamp(18px, 5vw, 76px) 34px;
  background:
    linear-gradient(110deg, rgba(21, 46, 85, 0.08), transparent 45%),
    linear-gradient(180deg, #fffdf8 0%, var(--paper) 100%);
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.hero p {
  max-width: 680px;
  color: #374151;
  font-size: 18px;
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.primary-action {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.secondary-action {
  color: var(--navy);
}

.hero-art {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.hero-art img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border: 1px solid #eef0f4;
  border-radius: 4px;
}

.hero-art figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin: 0 clamp(18px, 5vw, 76px) 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9ef;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--gold));
  transition: width 220ms ease;
}

.course-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  padding: 0 clamp(18px, 5vw, 76px) 56px;
}

.module-list {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.module-list h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.module-button {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  cursor: pointer;
}

.module-button[aria-current="true"] {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.module-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff;
  border-radius: 8px;
  background: var(--navy);
  font-weight: 800;
}

.module-button strong,
.module-button span {
  display: block;
}

.module-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.module-button.complete .module-number {
  background: var(--green);
}

.lesson-panel {
  min-height: 650px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.08);
}

.lesson-kicker {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-panel h2 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 50px);
  line-height: 1.04;
  letter-spacing: 0;
}

.lesson-summary {
  max-width: 860px;
  color: #374151;
  font-size: 18px;
  line-height: 1.65;
}

.lesson-art {
  position: relative;
  min-height: 132px;
  margin: 24px 0 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 34%, rgba(255, 255, 255, 0.92) 0 8%, transparent 9%),
    linear-gradient(135deg, rgba(31, 93, 153, 0.13), rgba(189, 139, 47, 0.16)),
    #f8fafc;
}

.lesson-art::before,
.lesson-art::after {
  position: absolute;
  content: "";
}

.lesson-art::before {
  inset: 24px auto auto 28px;
  width: 78px;
  height: 78px;
  border-radius: 999px;
  background: var(--navy);
  box-shadow:
    96px 18px 0 -16px var(--red),
    178px -4px 0 -26px var(--gold),
    272px 22px 0 -18px var(--green);
}

.lesson-art::after {
  right: 28px;
  bottom: 24px;
  width: 38%;
  height: 56px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 9%, rgba(255, 255, 255, 0.72) 9% 11%, transparent 11% 20%) repeat-x,
    rgba(21, 46, 85, 0.13);
  background-size: 48px 100%;
}

.lesson-art.history {
  background:
    linear-gradient(120deg, rgba(21, 46, 85, 0.15), rgba(180, 58, 53, 0.12)),
    #f8fafc;
}

.lesson-art.ideals {
  background:
    radial-gradient(circle at 25% 50%, rgba(189, 139, 47, 0.26) 0 7%, transparent 8%),
    radial-gradient(circle at 50% 48%, rgba(63, 111, 95, 0.24) 0 7%, transparent 8%),
    radial-gradient(circle at 75% 50%, rgba(31, 93, 153, 0.24) 0 7%, transparent 8%),
    #f8fafc;
}

.lesson-art.stars::before {
  width: 84px;
  height: 84px;
  clip-path: polygon(50% 0, 61% 36%, 98% 36%, 68% 57%, 79% 92%, 50% 70%, 21% 92%, 32% 57%, 2% 36%, 39% 36%);
  border-radius: 0;
  background: var(--gold);
  box-shadow:
    98px 0 0 -8px var(--gold),
    196px 0 0 -8px var(--gold),
    294px 0 0 -8px var(--gold),
    392px 0 0 -8px var(--gold);
}

.lesson-art.award {
  background:
    linear-gradient(90deg, rgba(21, 46, 85, 0.1), transparent 35%),
    linear-gradient(135deg, rgba(189, 139, 47, 0.22), rgba(255, 255, 255, 0.8)),
    #f8fafc;
}

.lesson-art.readiness {
  background:
    linear-gradient(135deg, rgba(63, 111, 95, 0.18), rgba(31, 93, 153, 0.15)),
    #f8fafc;
}

.video-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.video-copy h3 {
  margin: 6px 0 8px;
  font-size: 20px;
}

.video-copy p {
  margin: 0;
  color: #374151;
  line-height: 1.55;
}

.video-copy ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.video-copy li {
  padding: 7px 10px;
  border: 1px solid rgba(21, 46, 85, 0.16);
  border-radius: 999px;
  color: var(--navy);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.video-frame {
  display: grid;
  min-height: 170px;
  border-radius: 8px;
  overflow: hidden;
  background: #0f1c31;
}

.video-frame video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 170px;
  object-fit: cover;
}

.video-placeholder {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 170px;
  padding: 18px;
  color: #fff;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(31, 93, 153, 0.48), rgba(180, 58, 53, 0.32)),
    #0f1c31;
}

.video-placeholder span,
.video-placeholder small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.video-placeholder strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.lesson-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.lesson-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.lesson-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.lesson-card p,
.lesson-card li {
  color: #374151;
  line-height: 1.55;
}

.lesson-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.activity-box,
.quiz-box,
.ai-quiz-box {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.activity-box {
  background: #f4f8f6;
}

.quiz-box {
  background: #fffaf0;
}

.ai-quiz-box {
  display: grid;
  gap: 14px;
  background: #f4f8fc;
}

.activity-box h3,
.quiz-box h3,
.ai-quiz-box h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.activity-box p,
.ai-quiz-box p {
  margin: 0;
  color: #374151;
  line-height: 1.55;
}

.ai-quiz-box button {
  justify-self: start;
  min-height: 40px;
  border: 1px solid var(--navy);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--navy);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.ai-chat-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(31, 93, 153, 0.2);
  border-radius: 8px;
  background: #fff;
}

.ai-chat-log {
  display: grid;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.ai-chat-message {
  max-width: 86%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-chat-message.learner {
  justify-self: end;
  background: #fffaf0;
}

.ai-chat-message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.ai-chat-message p {
  margin: 0;
}

.ai-question-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(31, 93, 153, 0.2);
  border-radius: 8px;
  background: #fff;
}

.ai-question-panel[hidden] {
  display: none;
}

.ai-chat-panel label,
.ai-question-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-chat-panel textarea,
.ai-question-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.quiz-option input {
  margin-top: 3px;
}

.quiz-feedback {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 800;
}

.quiz-feedback.correct {
  color: var(--green);
}

.quiz-feedback.incorrect {
  color: var(--red);
}

.lesson-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.lesson-actions button {
  color: var(--navy);
}

#markComplete {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.sources-section {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(320px, 1fr);
  gap: 24px;
  padding: 54px clamp(18px, 5vw, 76px) 76px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.sources-section h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
}

.sources-section p {
  color: #374151;
  line-height: 1.65;
}

.source-grid {
  display: grid;
  gap: 12px;
}

.source-grid a {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  background: var(--paper);
}

.source-grid strong,
.source-grid span {
  display: block;
}

.source-grid span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.admin-page {
  padding: 28px clamp(18px, 5vw, 76px) 70px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.55fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.admin-grid.wide {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
}

.admin-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.07);
}

.admin-card h1,
.admin-card h2 {
  margin: 0 0 14px;
}

.admin-card h3 {
  margin: 22px 0 10px;
}

.invite-link {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid rgba(31, 93, 153, 0.18);
  border-radius: 8px;
  background: #f4f8fc;
}

.invite-link span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.invite-link code {
  padding: 10px;
  border-radius: 8px;
  overflow-wrap: anywhere;
  background: #fff;
}

.invite-link input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.invite-link a {
  color: var(--blue);
  font-weight: 800;
}

.admin-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.feedback-cell {
  min-width: 260px;
  max-width: 420px;
  line-height: 1.45;
}

.review-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.review-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-list dd {
  margin: 0;
  font-weight: 800;
}

.muted-note {
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 940px) {
  .topbar,
  .topnav {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .hero,
  .course-shell,
  .sources-section,
  .status-panel,
  .video-panel,
  .admin-grid,
  .admin-grid.wide {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .module-list {
    position: static;
    max-height: none;
  }
}

@media (max-width: 620px) {
  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .brand-primary {
    width: 150px;
    max-height: 42px;
  }

  .legion-emblem {
    width: 42px;
    height: 42px;
  }

  .topnav {
    width: 100%;
    overflow-x: auto;
  }

  .hero h1 {
    font-size: 36px;
  }

  .hero p,
  .lesson-summary {
    font-size: 16px;
  }

  .lesson-body {
    grid-template-columns: 1fr;
  }

  .lesson-art::after {
    width: 46%;
    right: 16px;
  }

  .lesson-actions {
    flex-direction: column;
  }
}
