:root {
  --color-navy: #0b2545;
  --color-navy-dark: #081b34;
  --color-teal: #14746f;
  --color-teal-light: #1c948d;
  --color-accent: #c9a227;
  --color-accent-dark: #a3821e;
  --color-bg: #f6f1e4;
  --color-surface: #fffdf8;
  --color-border: #e3dcc8;
  --color-text: #1b232c;
  --color-text-muted: #5a6672;
  --color-danger: #b3261e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(11, 37, 69, 0.08), 0 1px 2px rgba(11, 37, 69, 0.06);
  --shadow-hover: 0 6px 16px rgba(11, 37, 69, 0.14);
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --font-sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  line-height: 1.5;
  background-color: var(--color-bg);
  background-image:
    radial-gradient(ellipse at top left, rgba(255, 255, 255, 0.55), transparent 55%),
    url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgNDAwIDQwMCI+CiAgPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMGIyNTQ1IiBzdHJva2Utd2lkdGg9IjEiPgogICAgPHBhdGggZD0iTTAsNjAgQzUwLDIwIDEwMCwxMDAgMTUwLDYwIEMyMDAsMjAgMjUwLDEwMCAzMDAsNjAgQzM1MCwyMCA0MDAsMTAwIDQwMCw2MCIgb3BhY2l0eT0iMC4wNSIvPgogICAgPHBhdGggZD0iTTAsMTQwIEM1MCwxODAgMTAwLDEwMCAxNTAsMTQwIEMyMDAsMTgwIDI1MCwxMDAgMzAwLDE0MCBDMzUwLDE4MCA0MDAsMTAwIDQwMCwxNDAiIG9wYWNpdHk9IjAuMDQ1Ii8+CiAgICA8cGF0aCBkPSJNMCwyMjAgQzUwLDE4MCAxMDAsMjYwIDE1MCwyMjAgQzIwMCwxODAgMjUwLDI2MCAzMDAsMjIwIEMzNTAsMTgwIDQwMCwyNjAgNDAwLDIyMCIgb3BhY2l0eT0iMC4wNSIvPgogICAgPHBhdGggZD0iTTAsMzIwIEM1MCwzNjAgMTAwLDI4MCAxNTAsMzIwIEMyMDAsMzYwIDI1MCwyODAgMzAwLDMyMCBDMzUwLDM2MCA0MDAsMjgwIDQwMCwzMjAiIG9wYWNpdHk9IjAuMDQ1Ii8+CiAgPC9nPgo8L3N2Zz4K"),
    url("img/sketch-motif.f927341e331b.svg");
  background-repeat: no-repeat, repeat, repeat;
  background-size: 100% 600px, 400px 400px, 460px 460px;
}

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

h1, h2, h3 { color: var(--color-navy); font-family: var(--font-serif); }

.rename-link {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  vertical-align: middle;
  margin-left: 0.4rem;
}
.rename-link:hover { color: var(--color-accent-dark); }

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.1rem;
}
.page-nav .back-link { margin-bottom: 0; }

.back-link {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--color-accent-dark); }

/* ---------- Nav bar ---------- */
.navbar {
  background: var(--color-navy);
  color: #fff;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--color-accent-dark), var(--color-accent), var(--color-accent-dark)) 1;
}
.navbar .brand {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.navbar .brand span { color: var(--color-accent); }
.navbar-links { display: flex; align-items: center; gap: 1.5rem; }
.navbar-links a { color: #dfe7ea; font-weight: 500; }
.navbar-links a:hover { color: var(--color-accent); text-decoration: none; }
.navbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--color-accent);
  font-weight: 600;
}
a.navbar-user:hover { color: #fff; text-decoration: none; }
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.user-avatar--placeholder { border-color: rgba(255, 255, 255, 0.2); }
.avatar-current {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 1.25rem;
}
.avatar-current .user-avatar { width: 56px; height: 56px; border-color: var(--color-border); }
.avatar-clear-form { margin-top: 1.5rem; }
.navbar-role {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-navy);
  background: var(--color-accent);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
}
.logout-form { display: inline; margin: 0; }
.logout-form button {
  background: none;
  border: none;
  color: #dfe7ea;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.logout-form button:hover { color: var(--color-accent); text-decoration: underline; }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-header { margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { margin: 0 0 0.25rem; }
.page-header p { margin: 0; color: var(--color-text-muted); }
.page-header-actions { display: flex; gap: 0.75rem; }

section + section { margin-top: 2.5rem; }

h2 {
  position: relative;
  padding-bottom: 0.6rem;
  margin-bottom: 1.25rem;
}
h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 6px;
  background-image: linear-gradient(var(--color-accent), var(--color-accent)),
    linear-gradient(var(--color-accent), var(--color-accent));
  background-size: 100% 1px, 100% 1px;
  background-position: top, bottom;
  background-repeat: no-repeat;
}

/* ---------- Cards / tile grid ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}
/* Cards in a row stretch to the tallest, and the tallest is decided by its
   own content -- nothing here sets a fixed height. Actions go to the bottom
   so the button rows line up across cards of differing text length. */
.tile-grid > .card {
  display: flex;
  flex-direction: column;
}
.tile-grid > .card .card-actions { margin-top: auto; }
.card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-teal);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(201, 162, 39, 0.12);
  padding: 1.25rem;
  transition: box-shadow 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-hover), inset 0 0 0 1px rgba(201, 162, 39, 0.2); }
.card::before, .card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--color-accent);
  opacity: 0.5;
  pointer-events: none;
}
.card::before { top: 7px; left: 7px; border-right: none; border-bottom: none; }
.card::after { bottom: 7px; right: 7px; border-left: none; border-top: none; }
.card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.card .card-meta { color: var(--color-text-muted); font-size: 0.88rem; margin-bottom: 0.75rem; }
.card .card-meta + .card-meta { margin-top: -0.5rem; }
.card .card-actions { display: flex; gap: 0.6rem 1rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* ---------- Drag-to-reorder ---------- */
[data-reorderable] .card[data-id] { cursor: grab; }
[data-reorderable] .card[data-id]:active { cursor: grabbing; }
.card.reorder-dragging { opacity: 0.45; }
.card.reorder-drag-over-before,
.card.reorder-drag-over-after,
.card.reorder-drag-over-top,
.card.reorder-drag-over-bottom {
  position: relative;
}
.card.reorder-drag-over-before::before,
.card.reorder-drag-over-after::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--color-accent);
}
.card.reorder-drag-over-before::before { left: -0.625rem; }
.card.reorder-drag-over-after::after { right: -0.625rem; }
.card.reorder-drag-over-top::before,
.card.reorder-drag-over-bottom::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--color-accent);
}
.card.reorder-drag-over-top::before { top: -0.625rem; }
.card.reorder-drag-over-bottom::after { bottom: -0.625rem; }

/* ---------- Course dashboard grid (fixed-column 2D placement) ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 1.25rem;
}
[data-course-reorder] .card[data-id] { cursor: grab; }
[data-course-reorder] .card[data-id]:active { cursor: grabbing; }
.grid-cell {
  /* A floor, not a ceiling: empty cells still read as drop targets, and a
     cell holding more content grows past this. */
  min-height: 190px;
  border-radius: var(--radius);
}
/* min-height rather than height: the card fills its cell, but content longer
   than the cell makes the card -- and so the grid row -- taller, instead of
   being squeezed into a fixed box. */
.grid-cell .card {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
/* Pushed to the bottom so buttons line up across a row whose cards have
   different amounts of text above them. */
.grid-cell .card .card-actions { margin-top: auto; }

/* ---------- Dashboard tile heading ---------- */
/* A wrapping row rather than a column, so the "edit" link stays beside the
   name; the code is forced onto its own line by flex-basis below. */
.card h3.tile-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.5rem;
  margin-bottom: 0.5rem;
}
.tile-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
}
.tile-name {
  font-size: 1.05rem;
  line-height: 1.3;
  /* long names wrap onto as many lines as they need rather than overflowing */
  overflow-wrap: anywhere;
}
.tile-code {
  /* full-width basis puts the code on its own line under the name */
  flex-basis: 100%;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.grid-cell--empty {
  border: 1px dashed var(--color-border);
}
.grid-cell--drag-over {
  outline: 2px dashed var(--color-accent);
  outline-offset: -2px;
  background: rgba(201, 162, 39, 0.08);
}

/* ---------- Course icons ---------- */
.course-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 0.5rem;
  border: 1px solid var(--color-border);
}
.course-icon--placeholder {
  opacity: 0.85;
}

/* ---------- Icon picker (course form) ---------- */
.icon-picker-label {
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 0.5rem;
}
.icon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.icon-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
}
.icon-option img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}
.icon-option-placeholder {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.icon-option--selected {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.35);
}

/* ---------- Question editor ---------- */
.question-preview {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.question-preview li { padding: 0.15rem 0; }
.question-preview--correct { color: var(--color-teal); font-weight: 600; }
.formset-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.formset-row input[type="text"] { margin: 0; }
.formset-inline-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.formset-arrow { color: var(--color-text-muted); }
.form-errors {
  list-style: none;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: rgba(179, 38, 30, 0.08);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius);
  color: var(--color-danger);
}
.quiz-section { margin-top: 2rem; }

/* ---------- Course days ---------- */
.course-day {
  border-left: 3px solid var(--color-border);
  padding-left: 1.1rem;
  margin-bottom: 2rem;
}
.course-day h2 { margin-bottom: 0.4rem; }
.course-day h3 { font-size: 1rem; margin: 1.1rem 0 0.5rem; }
.course-day-agenda { color: var(--color-text-muted); line-height: 1.6; }

/* ---------- Notifications ---------- */
.notification-bell {
  position: relative;
  display: inline-block;
  font-size: 1.15rem;
  line-height: 1;
  color: #fff;
  text-decoration: none;
}
.notification-bell:hover { color: var(--color-accent); text-decoration: none; }
.notification-badge {
  position: absolute;
  top: -0.45rem;
  right: -0.6rem;
  min-width: 1.05rem;
  padding: 0 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  color: var(--color-navy);
  background: var(--color-accent);
  border-radius: 999px;
}
.notification-list { margin: 1.25rem 0; }
.notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
}
.notification--unread { border-left-color: var(--color-accent); }
.notification-body { flex: 1 1 320px; }
.notification-message { margin: 0 0 0.2rem; }
.notification--unread .notification-message { font-weight: 600; }
.notification-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Flash messages ---------- */
.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-bottom: 0.5rem;
}
.message--error {
  border-color: var(--color-danger);
  background: rgba(179, 38, 30, 0.08);
  color: var(--color-danger);
}
.message--success {
  border-color: var(--color-teal);
  background: rgba(20, 116, 111, 0.1);
  color: var(--color-teal);
}

.course-code {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-navy);
  background: rgba(201, 162, 39, 0.22);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  margin-right: 0.45em;
  vertical-align: middle;
}

/* ---------- Course runs & assignment timing ---------- */
.run-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.run-summary h2 { font-size: 0.95rem; margin: 0.75rem 0 0.4rem; }
.run-summary h2:first-child { margin-top: 0; }
.run-summary ul { margin: 0 0 0.5rem 1.2rem; font-size: 0.9rem; }
.run-summary li { margin-bottom: 0.2rem; }

.timing-picker ul { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.timing-picker li { margin-bottom: 0.25rem; }
.timing-picker label { font-weight: 400; }
.timing-option { padding-left: 1.4rem; }

/* ---------- Syllabus ---------- */
.syllabus-editor {
  background: #fff;
  min-height: 320px;
  margin-bottom: 1rem;
}
.syllabus-editor .ql-editor { min-height: 280px; font-size: 0.98rem; }

.syllabus-body {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  max-width: 820px;
  line-height: 1.65;
}
.syllabus-body h1,
.syllabus-body h2,
.syllabus-body h3,
.syllabus-body h4 {
  font-family: var(--font-serif);
  color: var(--color-navy);
  margin: 1.6rem 0 0.6rem;
}
.syllabus-body h1:first-child,
.syllabus-body h2:first-child,
.syllabus-body h3:first-child { margin-top: 0; }
.syllabus-body p { margin: 0 0 1rem; }
.syllabus-body ul,
.syllabus-body ol { margin: 0 0 1rem 1.4rem; }
.syllabus-body li { margin-bottom: 0.35rem; }
.syllabus-body blockquote {
  margin: 0 0 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-muted);
}
.syllabus-body pre,
.syllabus-body code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
}
.syllabus-body hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 1.5rem 0;
}

/* ---------- Step-by-step quiz ---------- */
.quiz-progress {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}
.reveal {
  border-left: 3px solid var(--color-border);
  padding: 0.25rem 0 0.25rem 1.1rem;
  margin-bottom: 1.5rem;
}
.reveal--correct { border-left-color: var(--color-teal); }
.reveal--incorrect { border-left-color: var(--color-danger); }
.reveal-verdict {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0.4rem 0 0.75rem;
  color: var(--color-navy);
}
.reveal--correct .reveal-verdict { color: var(--color-teal); }
.reveal--incorrect .reveal-verdict { color: var(--color-danger); }
.reveal-detail { margin: 0; }
.reveal-detail dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 0.6rem;
}
.reveal-detail dd { margin: 0.15rem 0 0; }

/* ---------- Survey report ---------- */
.response-entry {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}
.response-entry summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-navy);
}
.response-entry summary .card-meta {
  display: inline;
  margin-left: 0.5rem;
  font-weight: 400;
}
.response-entry table { margin-top: 0.75rem; }

/* ---------- Grading & feedback ---------- */
.grade-form-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.grade-form textarea {
  width: 100%;
  min-width: 240px;
  margin: 0;
  font-size: 0.88rem;
}

.grade-result {
  border-left: 3px solid var(--color-accent);
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}
.feedback-block { margin-top: 0.75rem; }
.feedback-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.feedback-text {
  margin: 0.25rem 0 0;
  line-height: 1.6;
  white-space: normal;
}

/* ---------- Online course rendering ---------- */
.learn-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 16rem) 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 48rem) {
  .learn-layout { grid-template-columns: 1fr; }
}

.learn-nav-module h2 {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}
.learn-nav-module ul {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
}
.learn-nav-module li { margin-bottom: 0.3rem; }
.learn-nav-module a.is-current {
  font-weight: 700;
  border-left: 3px solid var(--color-accent);
  padding-left: 0.5rem;
}

.learn-content .block { margin-bottom: 1.5rem; }
.block--image img { max-width: 100%; height: auto; }
.block--image figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
}

/* ---------- Transcript mode ---------- */
/* Purely presentational. Nothing here hides media: what transcript mode does
   is decline to *render* the tags at all, in the template, because a hidden
   <img> costs the same download as a visible one. These rules only mark the
   stand-in text as a stand-in, so a learner can tell the difference between
   "this is the whole block" and "something is missing". */
.transcript-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
  border-radius: 0.35rem;
  font-size: 0.9rem;
}
.transcript-toggle-state { flex: 1 1 auto; }
.transcript-toggle button { width: auto; }

.block--transcript {
  border-left: 3px solid var(--color-border, rgba(0, 0, 0, 0.2));
  padding-left: 0.75rem;
}
.transcript-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}
/* The alt text is the content here, not a footnote to it, so it is set as
   body copy rather than in the muted caption style. */
.transcript-alt { margin: 0 0 0.35rem; }
.block--transcript figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
}
/* The inline stand-in for a popup: distinguished from the surrounding page
   the way the modal panel would have been, since it is still a digression
   rather than part of the main flow. */
.block--popup-inline {
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
  border-radius: 0.35rem;
  padding: 0.75rem 1rem;
}
.block--popup-inline h4 { margin-top: 0; }

/* ---------- Reviewer assignment ---------- */
.reviewer-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.reviewer-form label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
}
.reviewer-form select { margin: 0; font-size: 0.85rem; }

/* Same shape as the reviewer picker -- they sit together on every module
   card, and two controls that do the same kind of thing should not look like
   two different kinds of thing. */
.status-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.status-form label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
}
.status-form select { margin: 0; font-size: 0.85rem; }

/* ---------- Inline image metadata ---------- */
.inline-meta {
  display: grid;
  gap: 0.25rem;
  margin: 0.4rem 0 0.6rem;
}
.inline-meta label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
}
.inline-meta input { margin: 0; font-size: 0.88rem; }

.draft-actions {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: 0.5rem;
}
.draft-actions form { display: inline; margin: 0; }

/* ---------- Page table of contents ---------- */
.page-toc {
  border-left: 3px solid var(--color-accent);
  padding: 0.6rem 0 0.6rem 1rem;
  margin-bottom: 1.75rem;
}
.page-toc h3 {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 0.4rem;
}
.page-toc ol { margin: 0; padding-left: 1.1rem; }
.page-toc li { margin-bottom: 0.25rem; }
.toc-kind {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: 0.4rem;
}
/* So an anchored jump does not tuck the block under the page heading. */
.block-anchor { scroll-margin-top: 1.5rem; }

/* ---------- Printable course ---------- */
.print-controls { margin-bottom: 2rem; }
.print-header { margin-bottom: 2rem; }
.print-module { margin-bottom: 2.5rem; }
.print-page { margin-bottom: 1.75rem; }
.print-figure img { max-width: 100%; height: auto; }
.print-note {
  border-left: 2px solid var(--color-text-muted);
  padding-left: 0.75rem;
  color: var(--color-text-muted);
}

@media print {
  /* Everything that is screen furniture, and nothing that is content. */
  .navbar,
  .page-nav,
  .print-controls,
  .sketch-defs,
  [data-ambient-gif] { display: none !important; }

  body { background: #fff; color: #000; }
  .container { max-width: none; margin: 0; padding: 0; }

  .print-module { page-break-inside: auto; }
  .print-page { page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
  .print-figure, .print-note { page-break-inside: avoid; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}

/* ---------- Authoring checks and bulk actions ---------- */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.bulk-select {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
  cursor: pointer;
}

.check-group { margin-bottom: 1.75rem; }
.check-group h3 { margin-bottom: 0.4rem; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-item {
  border-left: 3px solid var(--color-danger, #a3342c);
  padding: 0.5rem 0 0.5rem 0.9rem;
  margin-bottom: 0.8rem;
}
/* Unverified is information, not a fault, so it does not use the alarm colour. */
.check-item--unverified { border-left-color: var(--color-text-muted); }

/* ---------- Course search, bookmarks, reading time ---------- */
.learn-search {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.learn-search input { margin: 0; min-width: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-minutes {
  display: block;
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

.search-results { list-style: none; margin: 1rem 0 0; padding: 0; }
.search-result {
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0 0.5rem 0.9rem;
  margin-bottom: 1.1rem;
}
.search-snippet {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.bookmark-form {
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-surface-alt, rgba(0, 0, 0, 0.08));
}
.bookmark-form textarea { width: 100%; max-width: 34rem; }

.bookmark-list { list-style: none; margin: 0; padding: 0; }
.bookmark {
  border-left: 3px solid var(--color-accent);
  padding: 0.6rem 0 0.6rem 0.9rem;
  margin-bottom: 1.1rem;
}
.bookmark-meta {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.bookmark-title {
  display: inline-block;
  font-weight: 700;
  margin: 0.2rem 0;
}
.bookmark-note {
  margin: 0.3rem 0 0;
  line-height: 1.6;
}

/* ---------- Embedded external pages ---------- */
.embed-frame {
  position: relative;
  /* 16:9, the shape most video and slide embeds expect */
  padding-top: 56.25%;
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.06));
  border-radius: 0.35rem;
  overflow: hidden;
}
.embed-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.embed-title {
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.embed-fallback,
.embed-caption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0;
}

/* ---------- Module review comments ---------- */
.comment-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-width: 42rem;
}
.comment {
  border-left: 3px solid var(--color-accent);
  padding: 0.6rem 0 0.6rem 0.9rem;
  margin-bottom: 1rem;
}
/* Resolved comments stay readable but recede, so open ones lead the eye. */
.comment--resolved {
  border-left-color: var(--color-text-muted);
  opacity: 0.68;
}
.comment-meta {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.comment-body {
  margin: 0.3rem 0 0.5rem;
  line-height: 1.6;
}
.comment-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.comment-actions form { margin: 0; }

/* ---------- Inline knowledge checks ---------- */
.block--check {
  border-left: 3px solid var(--color-accent);
  padding: 1rem 1.1rem;
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.03));
  border-radius: 0 0.35rem 0.35rem 0;
}
.check-question { font-weight: 700; margin: 0 0 0.75rem; }

.check-choice {
  display: block;
  margin-bottom: 0.4rem;
  cursor: pointer;
}
.check-choice--wrong { color: var(--color-danger, #a3342c); }
.check-choice--right { font-weight: 700; }

.check-verdict {
  font-weight: 700;
  margin: 0 0 0.6rem;
}
.check-verdict--right { color: var(--color-accent); }
.check-verdict--wrong { color: var(--color-danger, #a3342c); }

.check-preview {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.92rem;
}

/* ---------- Module branching map ---------- */
.map-canvas {
  overflow-x: auto;
  margin: 1rem 0 2rem;
  padding-bottom: 0.5rem;
}

.map-node-box {
  fill: var(--color-surface, #fff);
  stroke: var(--color-accent);
  stroke-width: 1.5;
}
.map-node-link { cursor: pointer; }
.map-node-link:hover .map-node-box {
  fill: var(--color-surface-alt, rgba(0, 0, 0, 0.04));
  stroke-width: 2.5;
}
.map-node--orphan .map-node-box {
  stroke-dasharray: 5 4;
}

.map-node-order {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--color-text-muted);
}
.map-node-title {
  font-size: 0.95rem;
  font-weight: 700;
  fill: var(--color-text, #1a2340);
}
.map-node-meta {
  font-size: 0.7rem;
  fill: var(--color-text-muted);
}

.map-edge {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.6;
}
/* Backward jumps read as exceptions, so they are drawn as such. */
.map-edge--backward {
  stroke-dasharray: 6 4;
  opacity: 0.75;
}
.map-edge--self { stroke-dasharray: 3 3; }
.map-arrowhead { fill: var(--color-accent); }

.map-list { margin: 0.5rem 0 0 1.1rem; padding: 0; }
.map-list li { margin-bottom: 0.5rem; }
.map-list .card-meta { display: block; }

/* ---------- Student-view preview bar ---------- */
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 0.6rem 1rem;
  border-radius: 0.35rem;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.9rem;
}
.preview-bar form { margin: 0; }
.preview-bar button {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  width: auto;
}

/* ---------- Progress through authored content ---------- */
.progress-summary { margin-bottom: 1.5rem; max-width: 32rem; }
.progress-bar {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.08));
  overflow: hidden;
}
.progress-bar-fill {
  display: block;
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .progress-bar-fill { transition: none; }
}

.nav-tally {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--color-text-muted);
}
.nav-state {
  display: inline-block;
  width: 1em;
  text-align: center;
  color: var(--color-text-muted);
}
.nav-state--done { color: var(--color-accent); font-weight: 700; }
.nav-state--started { color: var(--color-text-muted); }

.block--embed {
  border: 1px solid var(--color-surface-alt, rgba(0, 0, 0, 0.12));
  border-radius: 0.4rem;
  padding: 1rem 1.1rem;
}
.block--embed h3 { margin: 0.35rem 0 0.5rem; }

.embed-return { margin-top: 1.5rem; }

.outstanding-list {
  margin: 0.4rem 0 0.9rem 1.1rem;
  padding: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.page-complete {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-surface-alt, rgba(0, 0, 0, 0.1));
}

/* ---------- Content popups ---------- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
/* The hidden attribute must win over display:flex. */
.popup-overlay[hidden] { display: none; }

.popup-panel {
  position: relative;
  background: var(--color-surface, #fff);
  border-radius: 0.5rem;
  padding: 2rem 1.75rem 1.5rem;
  max-width: 40rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.2rem 0.4rem;
  width: auto;
}
body.popup-open { overflow: hidden; }

/* ---------- Private staff notes ---------- */
.note-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  max-width: 32rem;
}
.note-item {
  border-left: 3px solid var(--color-accent);
  padding: 0.4rem 0 0.4rem 0.75rem;
  margin-bottom: 0.6rem;
}
.note-meta {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.note-content {
  margin: 0.25rem 0 0.4rem;
  line-height: 1.6;
}
.note-empty {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
}
.notice--staff {
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.03));
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.award-form { display: inline-block; margin-top: 0.35rem; }
.revoke-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.revoke-form input[type="text"] {
  margin: 0;
  font-size: 0.82rem;
  padding: 0.25rem 0.4rem;
  max-width: 190px;
}

.pending-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.prerequisite-picker ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  columns: 2;
}
.prerequisite-picker li { break-inside: avoid; }
.prerequisite-picker label { font-weight: 400; }

.badge--danger {
  background: rgba(179, 38, 30, 0.12);
  color: var(--color-danger);
}
.card-meta--warning { color: var(--color-danger); }

/* ---------- Roleplay board ---------- */
.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 15rem;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1000px) {
  .board-layout { grid-template-columns: 1fr; }
}

/* The grid can be wider than the page with several roles; scroll it inside
   its own box rather than letting the whole page scroll sideways. */
.board-grid-wrap { overflow-x: auto; }
.board-grid { width: 100%; border-collapse: collapse; }
.board-grid th,
.board-grid td {
  border: 1px solid var(--color-border);
  vertical-align: top;
  padding: 0.5rem;
}
/* The global `th` rule is navy-on-white for dark table headers. This grid
   wants light headers, so the colour has to be restated as well as the
   background -- overriding only the background leaves white text on a pale
   surface, which is invisible rather than merely wrong. */
.board-grid th {
  background: var(--color-surface);
  color: var(--color-navy);
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.9rem;
}
/* Same reason: meta text inside a header would otherwise inherit #fff. */
.board-grid th .card-meta { color: var(--color-text-muted); }
.board-corner { width: 13rem; }
.board-session { width: 13rem; }
.board-session-label { font-weight: 700; color: var(--color-navy); }

.board-cell { min-width: 8rem; min-height: 3.5rem; background: var(--color-surface); }
.board-cell--empty { background: var(--color-surface-alt, rgba(0, 0, 0, 0.02)); }
/* Same feedback convention as the course grid: the target lights up, the
   thing being dragged fades. */
.board-cell--drag-over {
  outline: 2px dashed var(--color-teal);
  outline-offset: -3px;
  background: rgba(20, 116, 111, 0.08);
}

.person-chip {
  display: inline-block;
  margin: 0.15rem 0.15rem 0.15rem 0;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 37, 69, 0.1);
  color: var(--color-navy);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: grab;
  user-select: none;
}
.person-chip:active { cursor: grabbing; }
.person-chip--dragging { opacity: 0.4; }

.board-pool {
  padding: 0.9rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.board-pool h2 { margin-top: 0; font-size: 1.05rem; }
.pool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  min-height: 4rem;
  padding: 0.35rem;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
}

.facilitator-form {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}
.facilitator-form label {
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0;
}
.facilitator-form select { margin: 0; font-size: 0.8rem; max-width: 8rem; }

/* ---------- Calendar feed ---------- */
.feed-url {
  padding: 0.6rem 0.8rem;
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  /* A subscription URL is long and has no spaces, so it must be allowed to
     break mid-token or it pushes the page sideways. */
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

/* ---------- Discussion board ---------- */
.topic-list { display: grid; gap: 0.75rem; margin-bottom: 1.5rem; }
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.topic-main h2 { margin: 0 0 0.2rem; font-size: 1.1rem; }
.topic-main h2 a { text-decoration: none; }
.topic-count { text-align: center; min-width: 4rem; }
.topic-count-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-teal);
}

.discussion-thread { display: grid; gap: 0.9rem; margin-bottom: 1.5rem; }
.discussion-post {
  padding: 0.8rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  /* Transparent rather than absent, so the staff variant below swaps a
     colour in without shifting the text by 3px. */
  border-left: 3px solid transparent;
  border-radius: 8px;
}

/* Staff input, made scannable in a long thread. Three cues rather than one:
   the navy edge, the tinted ground, and the role badge in the markup. Colour
   alone would be invisible to a reader who cannot distinguish it, and a badge
   alone is easy to miss when skimming. */
.discussion-post--staff {
  border-left-color: var(--color-navy);
  background: linear-gradient(
    to right,
    rgba(11, 37, 69, 0.06),
    var(--color-surface) 40%
  );
}
.discussion-post--staff .discussion-author { color: var(--color-navy); }

.discussion-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.discussion-author { font-weight: 700; }
.discussion-role { text-transform: none; }
.discussion-body { font-size: 0.95rem; }
.discussion-body p { margin: 0 0 0.5rem; }
.discussion-body p:last-child { margin-bottom: 0; }

.discussion-reply { margin-top: 0.5rem; }
.discussion-reply summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-teal);
}
.discussion-reply textarea { width: 100%; margin: 0.4rem 0; }

/* Indent, with a rule down the left so a reply chain reads as one. */
.discussion-replies {
  margin: 0.75rem 0 0 1.25rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--color-border);
  display: grid;
  gap: 0.75rem;
}
@media (max-width: 700px) {
  /* Three levels of indent is most of a phone screen; keep the rule, drop
     most of the offset. */
  .discussion-replies { margin-left: 0.35rem; padding-left: 0.6rem; }
}

/* ---------- AI assistant ---------- */
.chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--color-navy);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.chat-launcher:hover { background: var(--color-navy-dark); }
.chat-launcher--blocked {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  max-width: 22rem;
  cursor: default;
}
.chat-launcher--blocked .chat-launcher-label {
  font-weight: 400;
  font-size: 0.8rem;
}
.chat-launcher-icon { font-size: 1.1rem; }
.chat-launcher-label { font-size: 0.9rem; font-weight: 600; }
.chat-launcher-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-navy-dark);
  font-size: 0.7rem;
  font-weight: 700;
}
@media print { .chat-launcher { display: none; } }

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
}
.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 1rem;
}
.chat-message {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: var(--color-surface-alt, rgba(0, 0, 0, 0.03));
  border-left: 3px solid var(--color-border);
}
.chat-message--user { border-left-color: var(--color-teal); }
.chat-message--assistant { border-left-color: var(--color-accent); }
.chat-role {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.chat-body { white-space: pre-wrap; }
.chat-compose { display: grid; gap: 0.5rem; }
.chat-compose textarea { width: 100%; }
.chat-history { list-style: none; padding: 0; margin: 0 0 1rem; }
.chat-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border);
}
.chat-history li.is-current { font-weight: 600; }
.chat-tools { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.chat-tools li { padding: 0.15rem 0; }

/* ---------- Certificate ---------- */
.certificate-actions {
  display: flex;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.certificate-sheet {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-hover);
  padding: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}

/* Double rule: a gold hairline inset within a heavier navy frame. */
.certificate-frame {
  position: relative;
  border: 3px solid var(--color-navy);
  outline: 1px solid var(--color-accent);
  outline-offset: 6px;
  padding: 3rem 3.5rem 2.5rem;
  text-align: center;
}

.certificate-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-accent-dark);
  margin: 0 0 0.75rem;
}

.certificate-title {
  font-family: var(--font-serif);
  font-size: 2.6rem;
  line-height: 1.15;
  color: var(--color-navy);
  margin: 0 0 1.75rem;
}

.certificate-lede {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
}

.certificate-recipient {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  color: var(--color-navy);
  margin: 0 0 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-accent);
  display: inline-block;
  min-width: 60%;
}

.certificate-course {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-teal);
  margin: 0 0 1.5rem;
}

.certificate-awarded {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-text);
  margin: 0 0 1rem;
}

.certificate-seal {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1.5rem;
}

.certificate-seal .sketch {
  width: 88px;
  height: 116px;
  color: var(--color-accent-dark);
}

.certificate-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  margin-top: 2rem;
  text-align: left;
}

.certificate-signature { flex: 0 1 320px; }
.certificate-signature-line {
  border-bottom: 1px solid var(--color-navy);
  height: 1.75rem;
}
.certificate-signature-name {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--color-navy);
  margin-top: 0.35rem;
}
.certificate-signature-role {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.certificate-verify { text-align: right; }
.certificate-verify-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
}
.certificate-code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--color-navy);
}

/* ---------- Print ----------
   A certificate is the one page meant to leave the app as paper, so the
   whole UI chrome is stripped and the sheet is laid out landscape. */
@media print {
  @page {
    size: landscape;
    margin: 12mm;
  }

  body {
    background: #fff !important;
    background-image: none !important;
  }

  /* app chrome that must never appear on the printed sheet */
  .navbar,
  .page-nav,
  .no-print,
  .certificate-actions,
  .notification-bell,
  .logout-form {
    display: none !important;
  }

  main.container {
    max-width: none;
    margin: 0;
    padding: 0;
    animation: none !important;
  }

  .certificate-sheet {
    border: 0;
    box-shadow: none;
    padding: 0;
    max-width: none;
  }

  .certificate-frame {
    padding: 2.5rem 3rem;
    /* keep the navy/gold rules and coloured type in the PDF */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .certificate-title { font-size: 2.3rem; }
  .certificate-recipient { font-size: 1.9rem; }
}

/* ---------- Instructor bio ---------- */
.instructor-bio {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0.4rem 0 0;
  padding-left: 0.7rem;
  border-left: 2px solid var(--color-border);
}

/* ---------- Course catalog filters ---------- */
.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}
.catalog-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.catalog-field label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-navy);
}
.catalog-field input,
.catalog-field select { min-width: 190px; margin: 0; }
.catalog-field--actions {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

/* ---------- Videos ---------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin: 1rem 0;
}
.video-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.video-title { margin: 0 0 0.35rem; font-size: 1rem; }
.video-description { color: var(--color-text-muted); font-size: 0.88rem; margin: 0 0 0.75rem; }
.video-player {
  width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  background: #000;
}
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* Shared attach sections (videos, instructional materials) */
.attach-section { margin-top: 2rem; }
.attach-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.attach-form label { font-weight: 600; color: var(--color-navy); }
.attach-hint { margin-top: 0.75rem; font-size: 0.88rem; }

/* ---------- Stat tiles (dashboard KPIs) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.stat-tile {
  background: var(--color-navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-tile .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--color-accent); line-height: 1.2; }
.stat-tile .stat-label { font-size: 0.8rem; color: #cdd7dc; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Panels (forms) ---------- */
.panel {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(201, 162, 39, 0.12);
  padding: 1.75rem;
  max-width: 640px;
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-accent);
  opacity: 0.5;
  pointer-events: none;
}
.panel::before { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.panel::after { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.panel--narrow { max-width: 460px; }
.panel--center { margin: 2rem auto; text-align: center; }
.panel h1, .panel h2 { margin-top: 0; }

form p { margin: 0.9rem 0; }

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin: 0 0 1.25rem;
}
fieldset:last-of-type { margin-bottom: 0; }
legend { font-family: var(--font-serif); font-weight: 700; color: var(--color-navy); padding: 0 0.5rem; }

label { display: block; margin: 0.75rem 0 0.3rem; font-weight: 500; color: var(--color-text); }
.choice-option { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin: 0.4rem 0; }
.choice-option input { width: auto; }
.match-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }
.match-row select { width: auto; flex: 1; max-width: 220px; }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--color-text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(20, 116, 111, 0.15);
}

/* ---------- Buttons ---------- */
.btn, button, input[type="submit"] {
  display: inline-block;
  background: var(--color-accent);
  color: var(--color-navy-dark);
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:hover, button:hover, input[type="submit"]:hover { background: var(--color-accent-dark); }
.btn-secondary { background: transparent; color: var(--color-teal); border: 1px solid var(--color-teal); }
.btn-secondary:hover { background: var(--color-teal); color: #fff; }
.btn-sm { padding: 0.32rem 0.75rem; font-size: 0.85rem; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
}
th, td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--color-border); }
th { background: var(--color-navy); color: #fff; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f7f9fa; }
td form { margin: 0; display: flex; gap: 0.5rem; align-items: center; }
td form input[type="number"] { width: 6rem; }

/* ---------- Misc ---------- */
.empty-state {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 1.5rem;
  text-align: center;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(90, 102, 114, 0.12);
  color: var(--color-text-muted);
  margin: 0 0.35rem 0.35rem 0;
}
.badge--gold { background: rgba(201, 162, 39, 0.15); color: var(--color-accent-dark); }
/* Recurring task cadence. Deliberately quiet -- it is an ongoing fact about
   the task, not a state change worth competing with Overdue for attention. */
.badge--repeat { background: rgba(11, 37, 69, 0.08); color: var(--color-navy); }

/* Grid/List switch on the shared libraries. The two buttons sit flush so they
   read as one control with a selected half, rather than two separate links. */
.view-toggle {
  display: inline-flex;
  gap: 0;
}
.view-toggle .btn { border-radius: 0; }
.view-toggle .btn:first-child { border-radius: 6px 0 0 6px; }
.view-toggle .btn:last-child { border-radius: 0 6px 6px 0; }

/* Sortable column headings: a link in a header should not look like body
   copy, and the arrow needs room not to reflow the row when it appears. */
table th a {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
table th a:hover { text-decoration: underline; }

/* Private 1:1 messaging. Sides are set by a modifier class the template adds
   by comparing sender to viewer, so one stylesheet serves both people. */
.message-thread {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.message-bubble {
  max-width: 44rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--color-surface, #fff);
  border: 1px solid rgba(90, 102, 114, 0.2);
}
.message-bubble--mine {
  align-self: flex-end;
  background: rgba(20, 116, 111, 0.08);
  border-color: rgba(20, 116, 111, 0.25);
}
.message-body p:last-child { margin-bottom: 0; }
.message-preview { color: var(--color-text-muted); }
.badge--teal { background: rgba(20, 116, 111, 0.15); color: var(--color-teal); }
/* Approved: distinct from published teal, since the whole point of the state
   is that it is signed off but not yet live. */
.badge--navy { background: rgba(11, 37, 69, 0.12); color: var(--color-navy); }
