.demo-page {
  background: #0b1120;
  color: var(--paper);
}

.demo-page .site-header {
  border-color: #2d3851;
  background: #0b1120;
  color: var(--paper);
}

.demo-page .brand {
  color: var(--paper);
}

.demo-page .brand img {
  filter: invert(1);
}

.demo-page main {
  display: block;
  width: min(100%, var(--content-width));
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.course-shell {
  min-width: 0;
  padding-block: clamp(2rem, 5vw, 4.5rem) 4rem;
}

.course-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(17rem, 0.65fr);
  column-gap: clamp(2rem, 6vw, 6rem);
  align-items: end;
  padding-bottom: clamp(2rem, 4vw, 3.5rem);
}

.course-heading .section-index {
  grid-column: 1 / -1;
  margin: 0 0 1rem;
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.course-heading h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(3.25rem, 7.5vw, 7rem);
  font-weight: 530;
  letter-spacing: -0.065em;
  line-height: 0.9;
}

.course-heading > p:not(.section-index) {
  max-width: 36rem;
  margin: 0;
  color: #b7c0d1;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
}

.course-facts {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 2rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid #2d3851;
  color: #d8dfeb;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  list-style: none;
}

.course-facts li::before {
  margin-right: 0.55rem;
  color: var(--lime);
  content: '•';
}

.course-entry-card {
  display: grid;
  width: min(100%, 52rem);
  min-height: 22rem;
  margin: 1rem auto 0;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  border: 1px solid #39455f;
  background: #11192b;
  align-content: center;
}

.eyebrow,
.context-label {
  margin: 0;
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.course-entry-card h2 {
  max-width: 16ch;
  margin: 0.75rem 0 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 540;
  letter-spacing: -0.045em;
  line-height: 1;
}

.course-entry-card > p:not(.eyebrow) {
  max-width: 38rem;
  margin: 1.25rem 0 0;
  color: #bbc5d6;
}

.course-entry-card > button,
.course-entry-actions {
  margin-top: 2rem;
}

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

.course-shell :is(button, select, summary) {
  min-height: 2.75rem;
}

.course-shell button,
.course-shell select {
  border: 1px solid #586681;
  border-radius: var(--radius-small);
  background: #151f35;
  color: var(--paper);
  font: inherit;
}

.course-shell button {
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 650;
  transition: transform 120ms var(--ease-out);
}

.course-shell button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.course-shell .button-primary {
  border-color: var(--lime);
  background: var(--lime);
  color: var(--ink);
}

.course-shell :focus-visible {
  outline-color: var(--focus-dark);
}

.course-workspace {
  display: grid;
  grid-template-columns: minmax(12rem, 0.55fr) minmax(28rem, 1.65fr) minmax(
      18rem,
      0.8fr
    );
  grid-template-areas:
    'topbar topbar topbar'
    'route stage context';
  min-width: 0;
  overflow: clip;
  border: 1px solid #39455f;
  background: var(--midnight);
}

.course-topbar {
  display: grid;
  grid-area: topbar;
  grid-template-columns: minmax(12rem, 1fr) auto auto auto;
  gap: 1rem;
  min-width: 0;
  min-height: 4.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #39455f;
  background: #0f1729;
  align-items: center;
}

.course-topbar > div {
  display: grid;
  min-width: 0;
}

.course-topbar .eyebrow {
  color: #8f9ab0;
}

.course-topbar strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-topbar p {
  margin: 0;
  color: #b6c0d1;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.course-route {
  grid-area: route;
  min-width: 0;
  max-height: 54rem;
  overflow-y: auto;
  border-right: 1px solid #39455f;
  background: #0f1729;
}

.course-route-list,
.course-route-list ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-chapter {
  padding: 1rem;
  border-bottom: 1px solid #2d3851;
}

.route-chapter-heading {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.5rem;
  color: #d7deea;
  font-size: 0.76rem;
  align-items: baseline;
}

.route-chapter-heading > span {
  color: #7e8aa1;
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.course-route-list ol {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.course-route-list ol > li {
  display: grid;
  grid-template-columns: 3.6rem minmax(0, 1fr);
  gap: 0.55rem;
  min-width: 0;
  padding: 0.55rem;
  border-left: 2px solid #3d4963;
  color: #8995aa;
  font-size: 0.7rem;
  line-height: 1.3;
}

.route-marker {
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.route-node-title {
  overflow-wrap: anywhere;
}

[data-route-status='completed'] {
  border-left-color: var(--cobalt) !important;
  color: #d8e0ef !important;
}

[data-route-status='current'] {
  border-left-color: var(--lime) !important;
  background: rgb(199 243 74 / 8%);
  color: var(--paper) !important;
}

[data-route-status='available'] {
  border-left-color: var(--coral) !important;
  color: #ffd0c9 !important;
}

[data-route-status='skipped'] {
  border-left-style: dashed !important;
  color: #7e8aa1 !important;
  text-decoration: line-through;
}

[data-route-status='upcoming'] {
  color: #69758c !important;
}

[data-route-status='draft'] {
  border-left-style: dashed !important;
  border-left-color: var(--lime) !important;
  color: var(--lime) !important;
}

.course-stage {
  grid-area: stage;
  min-width: 0;
  min-height: 42rem;
  padding: clamp(1.5rem, 3.5vw, 3.5rem);
  background:
    linear-gradient(rgb(255 255 255 / 2%), rgb(255 255 255 / 0%)), #141b2d;
}

.activity-heading {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #39455f;
}

.activity-heading h2,
[data-course-recap] h2 {
  max-width: 18ch;
  margin: 0.75rem 0 0;
  font-size: clamp(2rem, 4vw, 3.75rem);
  font-weight: 540;
  letter-spacing: -0.05em;
  line-height: 0.98;
}

.activity-heading > p:last-child,
[data-course-recap] > p {
  max-width: 42rem;
  margin: 1rem 0 0;
  color: #b7c0d1;
}

.retrieval-target,
.attempt-feedback {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--lime);
  background: #10182a;
  color: #dce4f0;
}

.attempt-feedback {
  border-left-color: var(--coral);
}

[data-course-activity] {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

[data-course-activity] fieldset {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

[data-course-activity] legend {
  max-width: 46rem;
  margin-bottom: 0.35rem;
  color: var(--paper);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  font-weight: 620;
  line-height: 1.35;
}

.activity-guidance {
  margin: -0.15rem 0 0.25rem;
  color: #99a5ba;
  font-family: var(--font-mono);
  font-size: 0.67rem;
}

.course-choice {
  position: relative;
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid #46536d;
  background: #111a2d;
  cursor: pointer;
  align-items: center;
}

.course-choice:has(input:checked) {
  border-color: var(--lime);
  background: rgb(199 243 74 / 8%);
}

.course-choice input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--lime);
}

.course-choice small {
  grid-column: 2;
  margin-top: -0.5rem;
  color: #8f9bb0;
}

[data-confidence-group] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 0.5rem !important;
}

[data-confidence-group] legend {
  grid-column: 1 / -1;
  font-size: 0.8rem;
}

.matching-row {
  display: grid;
  grid-template-columns: minmax(10rem, 0.9fr) minmax(12rem, 1.1fr);
  gap: 1rem;
  min-width: 0;
  padding-block: 0.75rem;
  border-bottom: 1px solid #303c55;
  align-items: center;
}

.matching-row label {
  color: #dce3ef;
  font-weight: 600;
}

.matching-row select {
  width: 100%;
  min-width: 0;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
}

[data-order-list] {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  counter-reset: route-order;
  list-style: none;
}

[data-order-list] > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0.65rem 0.65rem 0.65rem 1rem;
  border: 1px solid #46536d;
  background: #111a2d;
  counter-increment: route-order;
  align-items: center;
}

.order-label::before {
  margin-right: 0.75rem;
  color: var(--lime);
  font-family: var(--font-mono);
  content: counter(route-order, decimal-leading-zero);
}

.order-controls {
  display: flex;
  gap: 0.35rem;
}

.order-controls button {
  width: 2.75rem;
  padding: 0;
}

[data-activity-error] {
  margin: 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--coral);
  background: #251b2a;
  color: #ffd5cf;
}

[aria-invalid='true'] {
  outline: 2px solid var(--coral);
  outline-offset: 4px;
}

.course-context {
  grid-area: context;
  min-width: 0;
  max-height: 54rem;
  overflow: auto;
  border-left: 1px solid #39455f;
  background: #0f1729;
}

.context-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  position: sticky;
  z-index: 2;
  top: 0;
  border-bottom: 1px solid #39455f;
  background: #0f1729;
}

.context-tabs button {
  min-width: 0;
  padding-inline: 0.5rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #8f9bb0;
  font-size: 0.68rem;
}

.context-tabs button[aria-selected='true'] {
  border-bottom-color: var(--lime);
  color: var(--paper);
}

[data-context-panel] {
  min-width: 0;
  padding: 1.25rem;
}

[data-context-panel] h3 {
  margin: 0.65rem 0 0;
  color: var(--paper);
  font-size: 1.15rem;
  line-height: 1.1;
}

[data-context-panel] p {
  color: #aeb9cb;
  font-size: 0.82rem;
}

[data-evidence-panel] > code {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.2rem 0.35rem;
  background: #1a2439;
  color: var(--lime);
  font-size: 0.68rem;
}

.route-decision {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #39455f;
}

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

.pack-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.pack-tabs button {
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.pack-tabs button[aria-selected='true'] {
  background: var(--lime);
  color: var(--ink);
}

.pack-tabs button[data-current-source='true']::after {
  display: block;
  color: currentColor;
  font-size: 0.5rem;
  content: 'current';
}

.course-context pre {
  max-width: 100%;
  max-height: 26rem;
  margin: 0;
  padding: 1rem;
  overflow: auto;
  border: 1px solid #39455f;
  background: #080e1b;
  color: #d7e2f4;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1.5;
  tab-size: 2;
}

.draft-toggle {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr);
  gap: 0.75rem;
  min-height: 2.75rem;
  margin-top: 1rem;
  cursor: pointer;
  align-items: center;
}

.draft-toggle input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--lime);
}

.context-note {
  padding-top: 0.75rem;
  border-top: 1px solid #39455f;
}

.recap-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 2rem 0;
  border-block: 1px solid #39455f;
}

.recap-stats > * {
  margin: 0;
  padding: 0.8rem;
}

.recap-stats dt {
  color: #8f9bb0;
  font-size: 0.7rem;
}

.recap-stats dd {
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  text-align: right;
}

.recap-route {
  margin-bottom: 1.5rem;
  border-top: 1px solid #39455f;
}

.recap-route summary {
  cursor: pointer;
}

.recap-route p {
  overflow-wrap: anywhere;
  color: #aeb9cb;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.static-course {
  max-width: 68rem;
  margin: 3rem auto 0;
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid #39455f;
  background: #11192b;
}

.static-course h2 {
  margin: 0.5rem 0 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

.static-course-heading > p:last-child,
.static-course section > p,
.static-course > p {
  color: #b7c0d1;
}

.static-chapters {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
}

.static-chapters > li,
.static-course section {
  padding: 1.25rem 0;
  border-top: 1px solid #39455f;
}

.static-chapters h3,
.static-course section h3 {
  margin: 0;
}

.static-chapters details {
  margin-top: 1rem;
}

html:not(.js) [data-course-entry] {
  display: none;
}

html:not(.js) [data-course-workspace] {
  display: none;
}

html:not(.js) .static-course summary {
  display: flex;
  min-height: 2.75rem;
  cursor: pointer;
  align-items: center;
}

@media (hover: hover) and (pointer: fine) {
  .course-shell button:active:not(:focus-visible) {
    transform: scale(0.97);
    transition-duration: 160ms;
  }

  .course-shell button:hover,
  .course-shell select:hover {
    border-color: var(--lime);
  }
}

@media (max-width: 72rem) {
  .course-workspace {
    grid-template-columns: minmax(10rem, 0.45fr) minmax(0, 1fr);
    grid-template-areas:
      'topbar topbar'
      'route stage'
      'context context';
  }

  .course-context {
    max-height: none;
    border-top: 1px solid #39455f;
    border-left: 0;
  }

  [data-context-panel] {
    min-height: 18rem;
  }

  .course-context pre {
    max-height: 20rem;
  }
}

@media (max-width: 52rem) {
  .course-heading {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .course-heading h1 {
    font-size: clamp(3rem, 15vw, 5.5rem);
  }

  .course-facts {
    margin-top: 0.5rem;
  }

  .course-workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      'topbar'
      'stage'
      'route'
      'context';
    overflow: visible;
  }

  .course-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .course-topbar > p {
    grid-column: 1 / -1;
  }

  .course-stage {
    order: 1;
    min-height: 0;
    padding: 1.25rem;
  }

  .course-route {
    order: 2;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    border-top: 1px solid #39455f;
    border-right: 0;
  }

  .course-route-list {
    display: flex;
    width: max-content;
  }

  .route-chapter {
    width: 16rem;
    flex: 0 0 16rem;
    border-right: 1px solid #2d3851;
    border-bottom: 0;
  }

  .course-context {
    order: 3;
  }

  .matching-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  [data-confidence-group],
  .recap-stats {
    grid-template-columns: 1fr;
  }

  .recap-stats dd {
    padding-top: 0;
    text-align: left;
  }
}

@media (max-width: 30rem) {
  .course-shell {
    padding-top: 1.5rem;
  }

  .course-heading h1 {
    font-size: clamp(2.75rem, 17vw, 4.5rem);
  }

  .course-topbar {
    grid-template-columns: 1fr;
  }

  .course-topbar > p {
    grid-column: auto;
  }

  .course-topbar button,
  .course-entry-actions button {
    width: 100%;
  }

  .context-tabs button {
    min-height: 3.25rem;
    font-size: 0.62rem;
  }

  [data-order-list] > li {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .course-shell * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
