.course-builder {
  display: grid;
  gap: 16px;
}

.builder-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.builder-toolbar-tight {
  align-items: center;
  margin-bottom: 12px;
}

.builder-toolbar h3 {
  margin: 0 0 6px;
}

.builder-toolbar p {
  margin: 0;
}

.question-editor-card {
  padding: 0;
  overflow: hidden;
}

.question-editor-details {
  display: grid;
}

.question-editor-details[open] {
  background: rgba(255, 255, 255, 0.32);
}

.question-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.question-editor-head-toggle {
  width: 100%;
  margin-bottom: 0;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.2s ease;
}

.question-editor-head-toggle:hover {
  background: rgba(24, 32, 28, 0.02);
}

.question-editor-head-toggle::-webkit-details-marker {
  display: none;
}

.question-editor-head-toggle::before {
  content: "▸";
  order: -1;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--brand-deep);
}

.question-editor-details[open] .question-editor-head-toggle::before {
  transform: rotate(90deg);
}

.question-editor-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.question-editor-badge {
  flex-shrink: 0;
}

.question-editor-head-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.question-editor-title-group {
  min-width: 0;
}

.question-editor-title-group h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
}

.question-editor-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.question-editor-head .text-button[hidden],
.option-editor-head .text-button[hidden],
.builder-toolbar[hidden] {
  display: none;
}

.question-editor-body {
  display: grid;
  gap: 16px;
  padding: 0 20px 20px;
}

.question-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.question-editor-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.question-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.question-editor-main,
.question-editor-side {
  min-width: 0;
}

.question-editor-side {
  display: grid;
  gap: 12px;
}

.question-editor-side .field {
  margin-bottom: 0;
}

.question-editor-hint {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(var(--brand-r), 0.14);
  background: rgba(231, 200, 149, 0.18);
  color: var(--muted-strong);
  font-size: 0.84rem;
  line-height: 1.55;
}

.question-editor-alert {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(163, 74, 58, 0.18);
  background: rgba(255, 244, 240, 0.88);
  color: #8b3d30;
  font-size: 0.84rem;
  line-height: 1.55;
}

.question-editor-alert[hidden] {
  display: none;
}

.question-editor-alert p {
  margin: 0;
}

.question-editor-alert p + p {
  margin-top: 8px;
}

.assignment-start-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-top: 18px;
  border-radius: 18px;
  border: 1px solid rgba(var(--brand-r), 0.18);
  background: rgba(247, 240, 227, 0.7);
}

.assignment-start-panel p,
.assignment-flow-note {
  margin: 6px 0 0;
  color: var(--muted);
}

.assignment-flow-note {
  font-size: 0.88rem;
}

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

.lesson-metric-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-soft);
}

.lesson-metric-card-current {
  border-color: rgba(var(--brand-r), 0.2);
  box-shadow: 0 16px 34px rgba(44, 37, 26, 0.1);
}

.lesson-metric-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lesson-metric-head strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  color: var(--ink);
}

.lesson-metric-card > p {
  margin: 10px 0 0;
  color: var(--ink);
  font-weight: 700;
}

.lesson-metric-meta {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.assignment-flow-panel {
  overflow: hidden;
}

.assignment-hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.assignment-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(34, 44, 39, 0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--brand-gold-r), 0.24), transparent 34%),
    linear-gradient(135deg, rgba(255, 252, 245, 0.98), rgba(242, 234, 217, 0.96));
  box-shadow: 0 24px 46px rgba(59, 43, 14, 0.09);
}

.assignment-hero-main {
  display: grid;
  gap: 12px;
}

.assignment-hero-main h1 {
  margin: 0;
  max-width: 18ch;
}

.assignment-hero-detail {
  margin: 0;
  max-width: 52rem;
  color: rgba(63, 52, 30, 0.78);
  font-size: 1rem;
}

.assignment-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.assignment-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.assignment-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.assignment-sidebar,
.assignment-main {
  display: grid;
  gap: 18px;
}

.assignment-summary-panel,
.assignment-feedback-panel,
.assignment-outline-panel,
.assignment-focus-panel {
  display: grid;
  gap: 16px;
}

.assignment-summary-detail {
  margin: -4px 0 0;
  color: var(--muted);
}

.assignment-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assignment-feedback-stack,
.assignment-lesson-list {
  display: grid;
  gap: 12px;
}

.assignment-feedback-lesson p:last-child {
  margin-bottom: 0;
}

.assignment-lesson-item {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.assignment-lesson-item-current {
  border-color: rgba(var(--brand-r), 0.2);
  box-shadow: 0 16px 34px rgba(44, 37, 26, 0.1);
}

.assignment-lesson-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.assignment-lesson-item p {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.assignment-lesson-item-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.assignment-focus-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.assignment-focus-header > div:first-child {
  min-width: 0;
  flex: 1;
}

.assignment-step-card {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.76);
}

.assignment-step-card h3,
.assignment-step-card p,
.assignment-focus-panel h2 {
  margin: 0;
}

.assignment-focus-panel-empty {
  min-height: 260px;
  align-content: center;
}

.lesson-flow-summary {
  margin-bottom: 8px;
}

.lesson-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.theory-pager {
  display: grid;
  gap: 14px;
}

.theory-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.theory-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(34, 44, 39, 0.08);
  background:
    radial-gradient(circle at top right, rgba(var(--brand-gold-r), 0.22), transparent 34%),
    linear-gradient(135deg, rgba(255, 252, 245, 0.98), rgba(244, 237, 222, 0.96));
  box-shadow: 0 24px 46px rgba(59, 43, 14, 0.09);
}

.theory-hero-main {
  display: grid;
  gap: 12px;
}

.theory-hero-main h1 {
  margin: 0;
  max-width: 14ch;
}

.theory-hero-course {
  margin: 0;
  max-width: 52rem;
  color: rgba(63, 52, 30, 0.78);
  font-size: 1rem;
}

.theory-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.danger-text {
  color: var(--danger, #9f2f2f);
}

.question-editor-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.question-editor-stat {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.68);
}

.question-editor-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.question-editor-stat strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.question-editor-divider {
  height: 1px;
  margin: 12px 0 10px;
  background: linear-gradient(90deg, rgba(24, 32, 28, 0.08), rgba(24, 32, 28, 0.02));
}

.question-editor-options-head {
  margin-bottom: 14px;
}

.question-editor-options-head strong {
  display: block;
  margin-bottom: 4px;
}

.question-editor-options-head p {
  color: var(--muted);
  font-size: 0.84rem;
}

.question-editor-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-items: stretch;
}

/* --- compact question layout --- */

.question-editor-compact-row {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 14px;
  align-items: start;
}

.question-type-field {
  margin-bottom: 0;
}

.question-editor-inline-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.question-media-field {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

/* --- compact options header --- */

.question-editor-options-head-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.question-editor-options-head-compact strong {
  font-size: 0.88rem;
}

.question-editor-option-counter,
.question-editor-correctness {
  font-size: 0.78rem;
  color: var(--muted);
}

.question-editor-options-head-compact .compact-button {
  margin-left: auto;
}

/* --- compact option rows --- */

.option-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.option-row-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 18px;
}

.option-row-input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  padding: 8px 0;
  outline: none;
}

.option-row-input:focus {
  border-bottom: 1px solid var(--brand-deep);
}

.option-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding-left: 12px;
  border-left: 1px solid rgba(24, 32, 28, 0.08);
  justify-self: end;
}

.option-row-correct {
  flex-shrink: 0;
  font-size: 0.82rem;
  gap: 6px;
  white-space: nowrap;
}

.option-row-remove {
  flex-shrink: 0;
  font-size: 0.82rem;
  line-height: 1.2;
  padding: 0;
  color: var(--danger, #8f2a2a);
  white-space: nowrap;
}

.option-row-remove:hover {
  color: var(--danger, #c0392b);
}

@media (max-width: 900px) {
  .option-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .option-row-badge {
    min-width: 0;
  }

  .option-row-actions {
    justify-content: space-between;
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid rgba(24, 32, 28, 0.08);
    padding-top: 10px;
  }
}

/* --- lesson settings details --- */

.lesson-settings-details {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.lesson-settings-toggle {
  cursor: pointer;
  list-style: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-strong);
  user-select: none;
}

.lesson-settings-toggle::-webkit-details-marker {
  display: none;
}

.lesson-settings-toggle::before {
  content: "▸ ";
  font-size: 0.7rem;
}

.lesson-settings-details[open] .lesson-settings-toggle::before {
  content: "▾ ";
}

.lesson-settings-body {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

/* --- lesson media fields --- */

.lesson-media-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.lesson-media-hint-placeholder {
  min-height: 1.2rem;
}

/* --- lesson video list --- */

.lesson-video-list {
  display: grid;
  gap: 6px;
}

.lesson-video-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  align-items: end;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.lesson-video-title-field {
  min-width: 0;
}

.lesson-video-row input[type="text"] {
  width: 100%;
  min-width: 0;
}

.lesson-video-order-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lesson-video-order {
  width: 100%;
}

.lesson-video-remove-toggle {
  min-height: 44px;
  align-self: end;
  padding-bottom: 10px;
}

.option-editor-card {
  display: grid;
  gap: 12px;
}

.option-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.option-editor-head .status-pill {
  font-size: 0.76rem;
}

.option-editor-card .field {
  margin-bottom: 0;
}

.option-editor-toggle {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(24, 32, 28, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.checkbox-line input {
  width: auto;
}

@media (max-width: 900px) {
  .lesson-video-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .lesson-video-remove-toggle {
    min-height: 0;
    padding-bottom: 0;
  }
}

.directory-selection-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.directory-selection-panel {
  border: 1px solid rgba(29, 35, 31, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  overflow: hidden;
}

.directory-selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.directory-selection-summary::-webkit-details-marker {
  display: none;
}

.directory-selection-summary-copy {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.directory-selection-summary-copy strong {
  font-size: 0.96rem;
}

.directory-selection-summary-chips {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.directory-selection-body {
  padding: 0 16px 16px;
  border-top: 1px solid rgba(29, 35, 31, 0.08);
}

.directory-selection-scroll {
  max-height: 248px;
  overflow: auto;
  padding-right: 4px;
  margin-top: 14px;
}

.directory-selection-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(29, 35, 31, 0.08);
}

.directory-selection-item:hover {
  border-color: rgba(var(--brand-r), 0.18);
  background: rgba(255, 255, 255, 0.84);
}

.lesson-panel-locked {
  opacity: 0.72;
}

.lesson-content {
  display: grid;
  gap: 14px;
  margin: 14px 0;
}

.theory-block-body {
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.7;
}

.theory-block-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.theory-block-body p,
.theory-block-body ul,
.theory-block-body ol,
.theory-block-body blockquote,
.theory-block-body pre,
.theory-block-body table {
  margin: 0.7em 0;
}

.theory-block-body p:first-child,
.theory-block-body ul:first-child,
.theory-block-body ol:first-child,
.theory-block-body blockquote:first-child,
.theory-block-body pre:first-child,
.theory-block-body table:first-child {
  margin-top: 0;
}

.theory-block-body p:last-child,
.theory-block-body ul:last-child,
.theory-block-body ol:last-child,
.theory-block-body blockquote:last-child,
.theory-block-body pre:last-child,
.theory-block-body table:last-child {
  margin-bottom: 0;
}

.theory-block-body a {
  color: var(--brand-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.theory-block-body h1,
.theory-block-body h2,
.theory-block-body h3,
.theory-block-body h4,
.theory-block-body h5,
.theory-block-body h6 {
  margin: 1em 0 0.35em;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.theory-block-body h1 { font-size: 1.4rem; }
.theory-block-body h2 { font-size: 1.2rem; }
.theory-block-body h3 { font-size: 1.05rem; }
.theory-block-body h4,
.theory-block-body h5,
.theory-block-body h6 { font-size: 0.95rem; }

.theory-block-body [style*="text-align:center"] {
  text-align: center;
}

.theory-block-body [style*="text-align:right"] {
  text-align: right;
}

.theory-block-body [style*="text-align:justify"] {
  text-align: justify;
}

.theory-block-body ul,
.theory-block-body ol {
  padding-left: 1.4rem;
}

.theory-block-body blockquote {
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--brand-soft);
  color: var(--muted-strong);
}

.theory-block-body table {
  width: 100%;
  border-collapse: collapse;
}

.theory-block-body th,
.theory-block-body td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.theory-block-body th {
  font-weight: 700;
  background: rgba(0, 0, 0, 0.03);
}

.theory-block-body pre,
.theory-block-body code {
  font-family: ui-monospace, monospace;
  font-size: 0.84rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
}

.theory-block-body code {
  padding: 2px 5px;
}

.theory-block-body pre {
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.media-card img,
.media-card video {
  width: 100%;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #111;
}

.lesson-video-asset-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px 14px;
  align-items: end;
  margin-top: 14px;
}

.lesson-video-order-field {
  max-width: 110px;
}

.lesson-video-remove-field {
  grid-column: 1 / -1;
}

.option-stack {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.inline-form {
  margin-top: 8px;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
