/* ──────────────────────────────────────────────────────────────────
   Rich lesson body · scoped styles (.rlp-*)
   Mounted inside the live course shell via mountRichLesson(rootEl, …).
   The course shell owns header, rail, tutor, and footer chrome — this
   stylesheet only paints the segment area + view-switcher tabs.
   ────────────────────────────────────────────────────────────────── */

.rlp {
  /* Palette — inherits the course shell ink/accent so it slots in. */
  --rlp-ink:        #1a1a2e;
  --rlp-ink-soft:   #3b3b54;
  --rlp-mute:       #6b6f80;
  --rlp-line:       #d9dbe4;
  --rlp-line-soft:  #ecedf2;
  --rlp-bg:         transparent;
  --rlp-paper:      #ffffff;
  --rlp-accent:     #2d5f8a;
  --rlp-accent-ink: #14385c;
  --rlp-accent-soft:#e7eef6;
  --rlp-warn:       #8a4a1f;
  --rlp-warn-soft:  #f5ebdc;
  --rlp-good:       #2f6b3a;
  --rlp-good-soft:  #e3efe5;

  --rlp-serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --rlp-sans:  "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --rlp-mono:  "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --rlp-radius: 4px;

  position: relative;
  color: var(--rlp-ink);
  font-family: var(--rlp-serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.rlp *,
.rlp *::before,
.rlp *::after { box-sizing: border-box; }

.rlp button { font-family: var(--rlp-sans); }

/* ── Top strip: progress + view-switcher tabs ─────────────────────── */
.rlp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 18px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--rlp-line);
}
.rlp-tabs {
  display: flex;
  gap: 2px;
}
.rlp-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 12px;
  font-family: var(--rlp-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--rlp-mute);
  cursor: pointer;
  margin-bottom: -1px;
  letter-spacing: 0.02em;
}
.rlp-tab:hover { color: var(--rlp-ink); }
.rlp-tab.is-current {
  color: var(--rlp-accent-ink);
  border-bottom-color: var(--rlp-accent);
}
.rlp-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 320px;
  font-family: var(--rlp-sans);
  font-size: 12px;
  color: var(--rlp-mute);
}
.rlp-progress-track {
  flex: 1;
  height: 3px;
  background: var(--rlp-line-soft);
  border-radius: 2px;
  overflow: hidden;
  min-width: 80px;
}
.rlp-progress-fill {
  height: 100%;
  background: var(--rlp-accent);
  transition: width 0.4s ease;
}
.rlp-progress-stats {
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ── Stage container ──────────────────────────────────────────────── */
.rlp-stage {
  min-height: 60vh;
  max-width: 44rem;
}
.rlp-empty {
  font-family: var(--rlp-sans);
  color: var(--rlp-mute);
  font-style: italic;
}

/* ── Segment view ────────────────────────────────────────────────── */
.rlp-segment {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.rlp-segment-head {
  border-bottom: 1px solid var(--rlp-line);
  padding-bottom: 14px;
}
.rlp-segment-eyebrow {
  font-family: var(--rlp-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rlp-mute);
  margin: 0 0 6px;
}
.rlp-segment-title {
  font-family: var(--rlp-serif);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--rlp-ink);
}

/* Audio strip — inline, not a panel */
.rlp-audio-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rlp-line-soft);
  font-family: var(--rlp-sans);
  font-size: 13px;
  color: var(--rlp-mute);
}
.rlp-audio-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rlp-accent);
  background: var(--rlp-paper);
  color: var(--rlp-accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.rlp-audio-button:hover { background: var(--rlp-accent); color: var(--rlp-paper); }
.rlp-audio-button.is-playing { background: var(--rlp-accent); color: var(--rlp-paper); }
.rlp-audio-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.rlp-audio-label {
  font-weight: 600;
  color: var(--rlp-ink);
  font-size: 13px;
}
.rlp-audio-sub {
  font-size: 11.5px;
  color: var(--rlp-mute);
  letter-spacing: 0.02em;
}
.rlp-audio-progress {
  flex: 0 0 120px;
  height: 3px;
  background: var(--rlp-line-soft);
  border-radius: 2px;
  overflow: hidden;
}
.rlp-audio-progress-fill {
  height: 100%;
  background: var(--rlp-accent);
  width: 0%;
}

/* Prose */
.rlp-prose p {
  margin: 0 0 14px;
  font-family: var(--rlp-serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--rlp-ink);
}
.rlp-prose p:last-child { margin-bottom: 0; }
.rlp-prose strong { color: var(--rlp-ink); font-weight: 700; }
.rlp-prose em { color: var(--rlp-ink-soft); }
.rlp-prose p.is-active {
  background: linear-gradient(transparent 60%, rgba(45,95,138,0.13) 60%);
  transition: background 0.4s ease;
}

/* Slide */
.rlp-slide {
  border-top: 1px solid var(--rlp-line);
  border-bottom: 1px solid var(--rlp-line);
  padding: 16px 0 16px 16px;
  background: linear-gradient(to right, var(--rlp-accent-soft) 0, var(--rlp-accent-soft) 3px, transparent 3px);
}
.rlp-slide-eyebrow {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rlp-accent);
  margin: 0 0 6px;
}
.rlp-slide-headline {
  font-family: var(--rlp-serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
  margin: 0 0 10px;
  color: var(--rlp-ink);
}
.rlp-slide-points {
  margin: 0;
  padding: 0 0 0 18px;
  font-family: var(--rlp-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--rlp-ink-soft);
}
.rlp-slide-points li { padding: 3px 0; }
.rlp-slide-eqn {
  margin: 10px 0 0;
  font-family: var(--rlp-mono);
  font-size: 14px;
  color: var(--rlp-accent-ink);
  background: var(--rlp-paper);
  border: 1px dashed var(--rlp-line);
  padding: 6px 10px;
  border-radius: var(--rlp-radius);
  display: inline-block;
}

/* Diagram */
.rlp-diagram { border-top: 1px solid var(--rlp-line); padding-top: 14px; }
.rlp-diagram svg { max-width: 100%; height: auto; display: block; }
.rlp-diagram-caption {
  margin: 8px 0 0;
  font-family: var(--rlp-sans);
  font-size: 12.5px;
  color: var(--rlp-mute);
  line-height: 1.45;
}

/* Worked example */
.rlp-worked {
  border-left: 2px solid var(--rlp-ink);
  padding: 6px 0 6px 14px;
}
.rlp-worked-label {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rlp-mute);
  margin: 0 0 4px;
}
.rlp-worked-title {
  font-family: var(--rlp-serif);
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 6px;
  color: var(--rlp-ink);
}
.rlp-worked-steps {
  margin: 0;
  padding-left: 18px;
  font-family: var(--rlp-sans);
  font-size: 14px;
  color: var(--rlp-ink-soft);
}
.rlp-worked-steps li { padding: 2px 0; }

/* Margin note */
.rlp-margin {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: var(--rlp-warn-soft);
  border-left: 2px solid var(--rlp-warn);
  font-family: var(--rlp-sans);
  font-size: 13px;
  color: var(--rlp-ink-soft);
  line-height: 1.5;
}
.rlp-margin-label {
  font-family: var(--rlp-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rlp-warn);
  font-weight: 700;
  flex-shrink: 0;
  width: 110px;
  padding-top: 2px;
}
.rlp-margin-body p { margin: 0 0 4px; }
.rlp-margin-body blockquote {
  margin: 6px 0 0;
  padding: 0;
  font-style: italic;
  color: var(--rlp-mute);
  font-size: 13px;
}

/* Inline checkpoint */
.rlp-check { border-top: 1px solid var(--rlp-line); padding-top: 14px; }
.rlp-check-eyebrow {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rlp-mute);
  margin: 0 0 6px;
}
.rlp-check-prompt {
  font-family: var(--rlp-serif);
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 10px;
  color: var(--rlp-ink);
}
.rlp-check-input {
  width: 100%;
  min-height: 70px;
  font-family: var(--rlp-serif);
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--rlp-line);
  border-radius: var(--rlp-radius);
  background: var(--rlp-paper);
  color: var(--rlp-ink);
  resize: vertical;
}
.rlp-check-input:focus {
  outline: none;
  border-color: var(--rlp-accent);
  box-shadow: 0 0 0 3px var(--rlp-accent-soft);
}
.rlp-check-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}
.rlp-button {
  font-family: var(--rlp-sans);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 14px;
  border-radius: var(--rlp-radius);
  border: 1px solid var(--rlp-accent);
  background: var(--rlp-accent);
  color: var(--rlp-paper);
  cursor: pointer;
  transition: background 0.15s ease;
  text-transform: uppercase;
}
.rlp-button:hover { background: var(--rlp-accent-ink); border-color: var(--rlp-accent-ink); }
.rlp-button.is-ghost {
  background: transparent;
  color: var(--rlp-accent);
}
.rlp-button.is-ghost:hover { background: var(--rlp-accent-soft); color: var(--rlp-accent-ink); }
.rlp-button.is-quiet {
  background: transparent;
  border-color: var(--rlp-line);
  color: var(--rlp-ink-soft);
}
.rlp-button.is-quiet:hover { border-color: var(--rlp-mute); color: var(--rlp-ink); }

.rlp-check-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--rlp-radius);
  font-family: var(--rlp-sans);
  font-size: 13px;
  line-height: 1.5;
  display: none;
}
.rlp-check-feedback.is-shown { display: block; }
.rlp-check-feedback.is-ok { background: var(--rlp-good-soft); color: var(--rlp-good); }
.rlp-check-feedback.is-miss { background: var(--rlp-warn-soft); color: var(--rlp-warn); }
.rlp-check-feedback strong { color: inherit; }
.rlp-check-hint {
  font-family: var(--rlp-sans);
  font-size: 12px;
  color: var(--rlp-mute);
}

/* Segment nav */
.rlp-segment-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rlp-line);
}
.rlp-segment-nav .rlp-button { min-width: 130px; }

/* Practice */
.rlp-practice-tabs {
  display: flex;
  gap: 4px;
  margin: 14px 0 18px;
  border-bottom: 1px solid var(--rlp-line);
}
.rlp-practice-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 7px 12px;
  font-family: var(--rlp-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rlp-mute);
  cursor: pointer;
  margin-bottom: -1px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rlp-practice-tab:hover { color: var(--rlp-ink); }
.rlp-practice-tab.is-current {
  color: var(--rlp-accent-ink);
  border-bottom-color: var(--rlp-accent);
}
.rlp-tier-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rlp-tier-item {
  border-top: 1px solid var(--rlp-line-soft);
  padding-top: 14px;
}
.rlp-tier-item:first-child { border-top: 0; padding-top: 0; }
.rlp-tier-num {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--rlp-mute);
  margin: 0 0 4px;
}
.rlp-tier-prompt {
  font-family: var(--rlp-serif);
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 10px;
  color: var(--rlp-ink);
}

/* Writing coach */
.rlp-writing-eyebrow {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rlp-mute);
  margin: 0 0 6px;
}
.rlp-writing-title {
  font-family: var(--rlp-serif);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.3;
  margin: 0 0 16px;
  color: var(--rlp-ink);
}
.rlp-writing-moves {
  border-left: 2px solid var(--rlp-accent);
  padding: 4px 0 4px 14px;
  margin: 0 0 18px;
  font-family: var(--rlp-sans);
  font-size: 13.5px;
}
.rlp-writing-moves-label {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rlp-accent);
  margin: 0 0 6px;
}
.rlp-writing-moves ol {
  margin: 0;
  padding-left: 18px;
  color: var(--rlp-ink-soft);
}
.rlp-writing-textarea {
  width: 100%;
  min-height: 180px;
  font-family: var(--rlp-serif);
  font-size: 16px;
  line-height: 1.6;
  padding: 14px 16px;
  border: 1px solid var(--rlp-line);
  border-radius: var(--rlp-radius);
  background: var(--rlp-paper);
  color: var(--rlp-ink);
  resize: vertical;
}
.rlp-writing-textarea:focus {
  outline: none;
  border-color: var(--rlp-accent);
  box-shadow: 0 0 0 3px var(--rlp-accent-soft);
}
.rlp-writing-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 18px;
}
.rlp-writing-count {
  font-family: var(--rlp-mono);
  font-size: 12px;
  color: var(--rlp-mute);
  margin-left: auto;
}

.rlp-rubric {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0 0 18px;
}
.rlp-rubric-item {
  display: grid;
  grid-template-columns: 22px 170px 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--rlp-line-soft);
  border-left: 3px solid var(--rlp-line);
  border-radius: 0 var(--rlp-radius) var(--rlp-radius) 0;
  background: var(--rlp-paper);
  font-family: var(--rlp-sans);
  font-size: 13px;
  color: var(--rlp-ink-soft);
}
.rlp-rubric-item.is-ok { border-left-color: var(--rlp-good); }
.rlp-rubric-item.is-miss { border-left-color: var(--rlp-warn); }
.rlp-rubric-mark { font-family: var(--rlp-mono); font-size: 14px; color: var(--rlp-mute); text-align: center; }
.rlp-rubric-item.is-ok .rlp-rubric-mark { color: var(--rlp-good); }
.rlp-rubric-item.is-miss .rlp-rubric-mark { color: var(--rlp-warn); }
.rlp-rubric-label { font-weight: 600; color: var(--rlp-ink); }
.rlp-rubric-note { color: var(--rlp-ink-soft); }

.rlp-exemplar { border-top: 1px solid var(--rlp-line); padding-top: 14px; }
.rlp-exemplar-label {
  font-family: var(--rlp-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rlp-mute);
  margin: 0 0 8px;
}
.rlp-exemplar-body p {
  font-family: var(--rlp-serif);
  font-size: 15.5px;
  line-height: 1.65;
  margin: 0 0 10px;
  color: var(--rlp-ink);
  font-style: italic;
}

@media (max-width: 720px) {
  .rlp-top { flex-direction: column; align-items: flex-start; }
  .rlp-progress { flex-basis: auto; width: 100%; }
  .rlp-rubric-item { grid-template-columns: 22px 1fr; }
  .rlp-rubric-label { grid-column: 2; }
  .rlp-rubric-note { grid-column: 1 / -1; padding-left: 34px; }
}

/* ── Course-shell rail extension: segment children under current rich lesson */
.rail-list li.segment-child {
  padding: 0;
}
.rail-list li.segment-child a,
.rail-list li.segment-child .segment-link {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  gap: 0.5rem;
  padding: 0.32rem 0.55rem 0.32rem 1.4rem;
  align-items: baseline;
  cursor: pointer;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}
.rail-list li.segment-child .code {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.66rem;
  color: var(--ghost, rgba(26,26,46,0.42));
  letter-spacing: 0.02em;
}
.rail-list li.segment-child span:nth-child(2) {
  font-size: 0.78rem;
  color: var(--muted, rgba(26,26,46,0.68));
}
.rail-list li.segment-child .state {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.6rem;
  color: var(--ghost, rgba(26,26,46,0.42));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.rail-list li.segment-child:hover {
  background: rgba(45,95,138,0.06);
}
.rail-list li.segment-child.current {
  background: rgba(45,95,138,0.10);
}
.rail-list li.segment-child.current span:nth-child(2) {
  color: var(--ink, #1a1a2e);
  font-weight: 600;
}
.rail-list li.segment-child.is-viewed .state {
  color: var(--ghost, rgba(26,26,46,0.42));
}
.rail-list li.segment-child.is-engaged .state {
  color: var(--amber, #b7791f);
}
.rail-list li.segment-child.is-engaged .state::before {
  content: "• ";
  color: var(--amber, #b7791f);
}
.rail-list li.segment-child.is-done .state {
  color: var(--green, #2a7d4f);
}
.rail-list li.segment-child.is-done .state::before {
  content: "✓ ";
  color: var(--green, #2a7d4f);
}

/* Experiment 3 generated bundle. */
.assessment-item[data-state="correct"] { border-left: 4px solid #2f7667; }
.assessment-item[data-state="incorrect"], .assessment-item[data-state="missing"] { border-left: 4px solid #a8483d; }
