/* Lesson create — rail UX + friendly educational workspace */

@keyframes lesson-rail-step-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.016); }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-create-page .quiz-rail-step.is-current:not(.is-done),
  .lesson-create-page .rail-step-ready.is-current:not(.is-done) {
    animation: none !important;
  }
}

.lesson-create-page .config-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.lesson-create-page .quiz-rail-head,
.lesson-create-page .quiz-stepper,
.lesson-create-page .rail-progress-slot,
.lesson-create-page .rail-progress-block {
  flex-shrink: 0;
}

.lesson-create-page .rail-progress-slot {
  flex: 0 0 118px;
  min-height: 118px;
  max-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.lesson-create-page .rail-progress-block {
  display: grid;
  grid-template-rows: 8px auto minmax(1.3em, 1.3em) minmax(1.25em, 1.25em);
  gap: 6px;
  min-height: 118px;
}

.lesson-create-page .rail-progress-block[hidden] {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}

.lesson-create-page .rail-progress-block .progress-track {
  background: #dbe5f2;
}

.lesson-create-page .rail-progress-block .progress-fill {
  background: linear-gradient(90deg, #34d399 0%, #10b981 100%);
}

.lesson-create-page .rail-progress-block.is-success .progress-fill,
.lesson-create-page .rail-progress-block .progress-fill.is-complete {
  background: #10b981;
}

.lesson-create-page .rail-progress-detail {
  margin: 0;
  min-height: 1.3em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-create-page .rail-progress-detail.is-error {
  color: #b91c1c;
}

.lesson-create-page .rail-progress-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted, #5b6f88);
  font-weight: 700;
}

.lesson-create-page .rail-progress-cost {
  margin: 0;
  min-height: 1.25em;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.25;
  color: #15803d;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-create-page .rail-progress-cost[hidden] {
  display: block !important;
  visibility: hidden;
}

.lesson-create-page .config-rail .rail-actions {
  margin-top: auto;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  z-index: 20;
  gap: 8px;
}

.lesson-create-page .rail-model-block {
  overflow: visible;
  position: relative;
  z-index: 30;
}

.lesson-create-page .model-picker-rail {
  overflow: visible;
}

.lesson-create-page .quiz-stepper .rail-step-ready {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy, #152a45);
  font: inherit;
  font-size: inherit;
  font-weight: 700;
  text-align: left;
  box-sizing: border-box;
  transition: background 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
}

.lesson-create-page .quiz-stepper .rail-step-ready.is-disabled {
  opacity: 0.55;
}

.lesson-create-page .quiz-stepper .rail-step-ready.is-done {
  opacity: 1;
}

.lesson-create-page .quiz-rail-step.is-current:not(.is-done),
.lesson-create-page .rail-step-ready.is-current:not(.is-done) {
  background: rgba(37, 99, 235, 0.07);
  border-color: transparent;
  box-shadow: none;
  animation: lesson-rail-step-pulse 2.8s ease-in-out infinite;
  transform-origin: center left;
}

.lesson-create-page .quiz-rail-step.is-current:not(.is-done) .quiz-rail-step-num {
  background: var(--blue, #2563eb);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
}

.lesson-create-page .rail-step-ready.is-current:not(.is-done) .quiz-rail-step-num {
  background: var(--blue, #2563eb);
  color: #fff;
}

.lesson-create-page .quiz-rail-step.is-done .quiz-rail-step-num,
.lesson-create-page .rail-step-ready.is-done .quiz-rail-step-num,
.lesson-create-page .quiz-rail-step.is-done.is-active .quiz-rail-step-num,
.lesson-create-page .quiz-rail-step.is-done.is-current .quiz-rail-step-num,
.lesson-create-page .rail-step-ready.is-done.is-current .quiz-rail-step-num {
  background: #16a34a !important;
  color: #fff !important;
  box-shadow: none !important;
}

.lesson-create-page .rail-actions .rail-btn-primary,
.lesson-create-page .rail-actions .btn-open,
.lesson-create-page .rail-actions .rail-narration-btn,
.lesson-create-page .rail-actions .rail-cancel-btn,
.lesson-create-page .rail-actions .rail-share-btn,
.lesson-create-page .rail-actions .rail-upload-stack button,
.lesson-create-page .rail-actions .rail-upload-stack a {
  min-height: 44px;
  height: 44px;
  max-height: 44px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.lesson-create-page .rail-actions .model-picker-trigger {
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  height: auto;
  min-height: 44px;
  max-height: none;
  white-space: normal;
  overflow: visible;
}

.lesson-create-page .rail-actions .rail-narration-btn.is-disabled,
.lesson-create-page .rail-actions .rail-narration-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.lesson-create-page .rail-actions .rail-cancel-btn[hidden] {
  display: none !important;
}

.lesson-create-page .rail-actions #btn-create-lesson.is-cancel-mode {
  background: #fff7ed !important;
  color: #9a3412 !important;
  border-color: #fdba74 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .lesson-create-page .rail-actions #btn-create-lesson.is-cancel-mode {
  background: linear-gradient(180deg, rgba(90, 45, 30, 0.95), rgba(60, 28, 18, 0.98)) !important;
  color: #ffd7bf !important;
  -webkit-text-fill-color: #ffd7bf !important;
  border-color: rgba(255, 154, 92, 0.55) !important;
}

.lesson-create-page .rail-actions #btn-create-lesson.is-cancel-mode:hover:not(:disabled) {
  background: #ffedd5 !important;
}

html[data-theme="dark"] .lesson-create-page .rail-actions #btn-create-lesson.is-cancel-mode:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(110, 55, 35, 0.98), rgba(70, 35, 22, 1)) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.lesson-create-page .model-picker-rail .model-picker-menu.is-floating {
  position: fixed;
  z-index: 10000;
  right: auto !important;
  left: auto;
  overflow-x: hidden;
}

/* Workspace — flush panel; zones are the feature boxes */
.lesson-workspace-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 14px;
  background: transparent;
}

.lesson-workspace-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 14px;
  height: 100%;
}

.lesson-ws-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  min-width: 0;
}

.lesson-ws-col--text {
  flex: 1;
  min-width: 0;
}

.lesson-ws-col--media {
  flex: 0 0 34%;
  width: 34%;
  min-width: 180px;
  max-width: 34%;
}

.lesson-ws-col > .lesson-ws-zone {
  flex: 1 1 0;
  min-height: 0;
}

.lesson-ws-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(47, 107, 255, 0.14);
  background: var(--edu-feature-box-grad, linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.92) 52%, rgba(236, 244, 255, 0.78) 100%));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 0 0 1px rgba(47, 107, 255, 0.06),
    0 8px 22px rgba(15, 41, 66, 0.07);
  transition: background 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.lesson-ws-zone.is-focused {
  background: var(--edu-feature-box-grad, linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 251, 255, 0.94) 52%, rgba(236, 244, 255, 0.82) 100%));
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 0 0 3px rgba(37, 99, 235, 0.08),
    0 8px 22px rgba(15, 41, 66, 0.07);
}

.lesson-ws-zone-head {
  flex-shrink: 0;
}

.lesson-ws-zone-head > span {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--navy, #152a45);
  letter-spacing: -0.01em;
}

.lesson-ws-zone-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lesson-ws-zone-body--illus {
  justify-content: stretch;
}

.lesson-ws-zone-foot {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.lesson-ws-zone-foot--illus {
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}

.lesson-ws-zone-body--settings {
  justify-content: flex-start;
  align-items: stretch;
  gap: 12px;
  padding-top: 2px;
}

.lesson-ws-text {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  resize: none;
  border: 1px solid rgba(47, 107, 255, 0.22);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: var(--fs-xs);
  line-height: 1.5;
  background: #ffffff;
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.98),
    0 2px 0 rgba(208, 222, 242, 0.62),
    0 3px 6px rgba(15, 41, 66, 0.05),
    0 8px 20px rgba(15, 41, 66, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.lesson-ws-text:focus {
  outline: none;
  border-color: rgba(255, 122, 61, 0.55);
  box-shadow:
    0 0 0 3px rgba(255, 122, 61, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.98),
    0 3px 8px rgba(47, 107, 255, 0.1),
    0 10px 24px rgba(15, 41, 66, 0.09);
  background: #fff;
}

.lesson-illus-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
  margin: 0;
}

.lesson-ws-zone-body--illus .lesson-illus-frame.q-illus-frame {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  height: 100%;
  min-height: 140px;
  max-height: none;
  aspect-ratio: unset;
}

.lesson-illus-alt-label {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
}

.lesson-illus-alt-label input {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: var(--fs-xs);
  background: #f7f9fc;
}

.lesson-setting-row {
  display: grid;
  gap: 6px;
}

.lesson-setting-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.lesson-segment {
  display: inline-flex;
  gap: 0;
  padding: 4px;
  border-radius: 999px;
  background: var(--line-soft, #f3f6fa);
  border: 1px solid var(--line, transparent);
  width: fit-content;
  max-width: 100%;
}

.lesson-segment-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  border-radius: 999px;
  min-width: 3.6em;
  padding: 7px 14px;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.lesson-segment-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lesson-segment-opt:has(input:checked) {
  background: color-mix(in srgb, var(--blue, #2563eb) 22%, transparent);
  color: var(--blue, #1d4ed8);
}

.lesson-segment-opt--yes:has(input:checked) {
  background: color-mix(in srgb, #16a34a 22%, transparent);
  color: #15803d;
}

.lesson-segment-opt--no:has(input:checked) {
  background: color-mix(in srgb, var(--muted, #64748b) 18%, transparent);
  color: var(--text, #475569);
}

.btn-image-ocr,
.btn-illus-upload {
  flex: 0 0 auto;
  border: 1px solid var(--line, #d5e4f7);
  background: var(--panel, #fff);
  color: var(--text, #152a45);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-image-ocr:hover,
.btn-illus-upload:hover {
  border-color: #93c5fd;
  background: color-mix(in srgb, var(--blue, #2563eb) 12%, var(--panel, #fff));
  color: var(--blue, #1d4ed8);
}

.btn-image-ocr[hidden] { display: none !important; }

.image-ocr-crop-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

@media (max-width: 900px) {
  .lesson-workspace-grid {
    flex-direction: column;
    overflow: auto;
  }

  .lesson-ws-col--media {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .lesson-ws-col > .lesson-ws-zone {
    flex: 1 1 auto;
    min-height: 140px;
  }

  .lesson-ws-text {
    min-height: 100px;
  }
}
