.toc-module {
  margin: 0 0 var(--space-6);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

.toc-item {
  background: var(--mshp-paper);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

.toc-item a {
  color: var(--mshp-text);
  text-decoration: none;
  font-weight: 700;
}

.toc-item a:hover {
  color: var(--mshp-sky-dark);
}

.toc-locked {
  color: var(--mshp-muted);
}

.toc-current {
  border-color: var(--mshp-sky);
  box-shadow: var(--focus-ring);
}

.toc-completed .status-label {
  color: var(--mshp-success);
}

.status-label {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--mshp-muted);
}

.lock-hint {
  width: 100%;
  margin: 0;
  font-size: 0.85rem;
  color: var(--mshp-muted-strong);
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(200px, 240px);
  gap: var(--space-5);
  align-items: start;
}

.lesson-layout-video {
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(200px, 240px);
}

.lesson-sidebar,
.lesson-context {
  background: var(--mshp-paper);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  position: sticky;
  top: 84px;
}

.sidebar-title {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
}

.course-toc-list,
.step-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

.course-toc-module {
  margin: 0 0 var(--space-3);
}

.course-toc-module h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mshp-muted);
  margin: 0 0 var(--space-2);
}

.course-toc-list a,
.step-nav-list a {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--mshp-text);
  padding: 8px 10px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.92rem;
}

.step-nav-title {
  flex: 1;
  min-width: 0;
}

.step-nav-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
  padding-top: 2px;
  white-space: nowrap;
}

.step-nav-done {
  color: var(--mshp-success);
}

.step-nav-type {
  color: var(--mshp-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-nav-type--sandbox .icon {
  width: 18px;
  height: 18px;
}

.course-toc-list a:hover,
.step-nav-list a:hover {
  background: var(--mshp-surface);
  text-decoration: none;
}

.course-toc-list .is-current a,
.step-nav-list .is-current a {
  background: var(--mshp-surface-3);
  color: var(--mshp-text);
  font-weight: 800;
}

.course-toc-list .is-done a,
.step-nav-list .is-done a {
  color: var(--mshp-success);
}

.step-nav-list .is-done .step-nav-type {
  color: var(--mshp-muted);
}

.course-toc-list .is-locked {
  color: var(--mshp-muted);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
}

.lesson-main {
  min-width: 0;
}

.lesson-main-card {
  background: var(--mshp-paper);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.lesson-main-card h1 {
  margin-top: 0;
}

.step-card {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
}

.step-card.is-highlight {
  outline: 2px solid var(--mshp-sky);
  outline-offset: 8px;
  border-radius: var(--radius-lg);
}

.embed {
  position: relative;
  padding-top: 56.25%;
  margin: 12px 0;
  background: var(--mshp-surface-2);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  text-align: center;
}

.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 var(--space-4);
  max-width: 100%;
}

.prose th,
.prose td {
  border: 1px solid var(--mshp-line);
  padding: 8px 12px;
  text-align: left;
}

.prose th {
  background: var(--mshp-surface);
  font-weight: 700;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.step-pager {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-6) 0 var(--space-4);
}

.question-box textarea,
.chat-composer textarea {
  width: 100%;
  min-height: 96px;
  padding: 8px 12px;
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-md);
  color: var(--mshp-text);
}

.question-threads {
  margin-top: var(--space-6);
}

.question-thread {
  border-top: 1px solid var(--mshp-line);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}

.quiz-options {
  display: grid;
  gap: var(--space-2);
  margin: 12px 0 16px;
}

.quiz-options label,
.quiz-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--mshp-surface);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 44px;
  cursor: pointer;
}

.quiz-options label:hover {
  border-color: var(--mshp-sky);
}

.quiz-options input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--mshp-sky);
}

.material-files {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.material-file {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  background: var(--mshp-surface);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.material-file-name {
  font-weight: 600;
  color: var(--mshp-text);
  word-break: break-word;
}

.material-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.material-files a {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}

#step-complete-slot form {
  margin-top: var(--space-6);
}

.quiz-option.is-chosen-correct {
  background: #e8f8f4;
  border-color: #bde8dc;
  color: var(--mshp-success);
  font-weight: 700;
}

.quiz-result-ok {
  color: var(--mshp-success);
  font-weight: 700;
}

.quiz-result-bad {
  color: var(--mshp-danger);
  font-weight: 700;
}

.sandbox {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-5) 0 0;
  padding: 16px;
  background: var(--mshp-surface);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-xl);
}

.sandbox-lang {
  margin: 0;
}

.sandbox-editor {
  height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--mshp-line);
  background: var(--mshp-paper);
}

.sandbox-io {
  display: grid;
  gap: var(--space-2);
}

.sandbox-io-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.sandbox-io-head label,
.sandbox-io-title {
  margin: 0;
  font-weight: 700;
}

.sandbox-stdin,
.sandbox-preview-code,
.sandbox-output {
  width: 100%;
  min-height: 96px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-md);
  color: var(--mshp-text-body);
  background: var(--mshp-paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.sandbox-preview-code,
.sandbox-output {
  min-height: 72px;
  white-space: pre-wrap;
  overflow: auto;
  resize: none;
}

.sandbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.sandbox-status {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.sandbox-status--ok {
  color: var(--mshp-success);
}

.sandbox-status--error,
.sandbox-status--wait {
  color: var(--mshp-danger);
}

.sandbox-status--wait {
  color: var(--mshp-warning);
}

.task-sample {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.task-sample h3 {
  margin: 0;
}

.task-results {
  display: grid;
  gap: var(--space-2);
}

.task-result-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.task-result-item {
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--mshp-paper);
}

.task-result-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.task-result-item summary::-webkit-details-marker {
  display: none;
}

.task-result-item summary::after {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
  flex-shrink: 0;
}

.task-result-item[open] summary::after {
  transform: rotate(225deg);
  margin-top: 4px;
}

.task-result-item summary + * {
  margin-top: var(--space-3);
}

.task-result-item.is-pass summary {
  color: var(--mshp-success);
}

.continue-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-6);
  background: var(--mshp-paper);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  margin-bottom: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.purchase-box {
  margin-top: var(--space-5);
  display: grid;
  gap: var(--space-3);
}

.purchase-meta {
  color: var(--mshp-muted-strong);
}

.success-panel {
  background: #e8f8f4;
  border: 1px solid #bde8dc;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: var(--space-5);
  min-height: 60vh;
  align-items: stretch;
}

.chat-list,
.chat-thread {
  background: var(--mshp-paper);
  border: 1px solid var(--mshp-line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-list a {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--mshp-line);
  color: var(--mshp-text);
  text-decoration: none;
}

.chat-list a:hover,
.chat-list a.is-active {
  background: var(--mshp-surface-2);
  text-decoration: none;
}

.chat-thread-body {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
  display: grid;
  gap: var(--space-3);
  align-content: start;
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--mshp-line);
}

.bubble--own {
  margin-left: auto;
  background: var(--mshp-surface-3);
}

.bubble--other {
  margin-right: auto;
  background: var(--mshp-surface);
}

.chat-composer {
  border-top: 1px solid var(--mshp-line);
  padding: var(--space-3);
}

.chat-thread-header {
  padding: var(--space-4) var(--space-4) 0;
}

.lesson-mobile-bar {
  display: none;
}

@media (max-width: 1024px) {
  .lesson-layout,
  .lesson-layout-video {
    grid-template-columns: minmax(200px, 240px) 1fr;
  }

  .lesson-context {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 768px) {
  .lesson-layout,
  .lesson-layout-video {
    grid-template-columns: 1fr;
  }

  .lesson-sidebar {
    display: none;
    position: fixed;
    z-index: 45;
    inset: 0 auto 0 0;
    width: min(320px, 90vw);
    overflow: auto;
    border-radius: 0;
    top: 0;
  }

  body.is-toc-open .lesson-sidebar {
    display: block;
  }

  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 35, 63, 0.35);
    z-index: 44;
  }

  body.is-toc-open .drawer-backdrop {
    display: block;
  }

  .lesson-mobile-bar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .chat-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .continue-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .step-pager {
    flex-direction: column;
  }

  .step-pager .button,
  .step-pager .button--secondary,
  .step-pager .button-secondary {
    width: 100%;
  }
}
