/* ============================================================
   BookCraft – Simplified AI Educational Authoring UX
   Goal: make the authoring flow feel simple for teachers
   ============================================================ */

:root {
  --primary-h: 239;
  --primary-s: 84%;
  --primary-l: 67%;
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-dark: hsl(var(--primary-h), var(--primary-s), 55%);
  --primary-light: hsl(var(--primary-h), var(--primary-s), 93%);
  --accent: hsl(187, 92%, 43%);
  --accent-light: hsl(187, 92%, 93%);
  --success: hsl(152, 69%, 41%);
  --success-light: hsl(152, 69%, 92%);
  --warning: hsl(38, 92%, 50%);
  --warning-light: hsl(38, 92%, 92%);
  --danger: hsl(0, 72%, 57%);
  --danger-light: hsl(0, 72%, 94%);
  --gray-50: hsl(220, 20%, 97%);
  --gray-100: hsl(220, 18%, 94%);
  --gray-200: hsl(220, 16%, 88%);
  --gray-300: hsl(220, 14%, 78%);
  --gray-400: hsl(220, 12%, 62%);
  --gray-500: hsl(220, 12%, 50%);
  --gray-600: hsl(220, 14%, 40%);
  --gray-700: hsl(220, 18%, 28%);
  --gray-800: hsl(220, 22%, 18%);
  --gray-900: hsl(220, 26%, 11%);
  --bg: var(--ss-bg, #f4f6fb);
  --surface: #ffffff;
  --surface-soft: #fbfcff;
  --border: #e8eef7;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: var(--gray-400);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
  --header-h: 66px;
  --sidebar-w: 320px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --ss-violet: #6d5efc;
  --ss-violet-soft: #ede9fe;
  --ss-blue: #3b82f6;
  --ss-bg: #f4f6fb;
  --ss-radius: 18px;
  --ss-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  line-height: 1.65;
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

textarea {
  resize: vertical;
}

#appHeader {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
}

.header-left {
  gap: 13px;
}

.header-right {
  gap: 10px;
  justify-content: flex-end;
}

.header-center {
  display: none !important;
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 1.18rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, hsl(239, 84%, 67%), hsl(187, 92%, 43%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.header-text .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.meta-chip {
  background: var(--gray-50);
  border: 1px solid var(--border);
  color: var(--gray-600);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.header-cta-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.header-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-right-actions {
  gap: 8px;
}

#headerActions:empty {
  display: none;
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  font-weight: 900;
  transition: var(--transition);
}

.btn {
  padding: 10px 14px;
}

.btn-sm {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.20);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(99, 102, 241, 0.26);
}

.btn-ghost {
  background: var(--surface);
  color: var(--gray-600);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-soft {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-soft:hover {
  background: hsl(var(--primary-h), var(--primary-s), 90%);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger-soft {
  background: var(--danger-light);
  color: var(--danger);
}

.icon-btn {
  width: 36px;
  height: 36px;
  background: var(--gray-50);
  color: var(--gray-600);
  border: 1px solid var(--border);
  font-size: 1.4rem;
}

.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.book-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

.main-panel {
  overflow-y: auto;
  padding: 22px;
  min-width: 0;
}

.side-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 15px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.project-card {
  background: linear-gradient(135deg, var(--surface), var(--primary-light));
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.project-card h2 {
  font-size: 1.07rem;
  font-weight: 900;
  margin: 4px 0;
}

.project-card p,
.compact-note {
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
}

.compact-note strong {
  display: block;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.compact-note ol {
  padding-right: 18px;
}

.compact-note li {
  margin: 5px 0;
}

.progress-card {
  font-size: 0.82rem;
}

.progress-card>strong {
  display: block;
  margin-bottom: 8px;
  color: var(--gray-800);
}

.progress-log {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.progress-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  align-items: start;
}

.progress-time {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.progress-message {
  color: var(--gray-700);
  font-weight: 700;
  line-height: 1.4;
}

.progress-line.success .progress-message {
  color: #047857;
}

.progress-line.error .progress-message {
  color: #b91c1c;
}

.catalog-loading {
  animation: catalogPulse 1.2s ease-in-out infinite;
}

.catalog-loading-state {
  opacity: 0.85;
}

@keyframes catalogPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.65;
  }
}

.lesson-topics-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 16px 18px;
  margin-bottom: 18px;
}

.lesson-topics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lesson-topics-head h4 {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--gray-800);
}

.topics-count {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 10px;
}

.lesson-topics-list {
  margin: 0;
  padding-right: 20px;
  display: grid;
  gap: 8px;
}

.lesson-topics-list li {
  color: var(--gray-700);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.55;
}

.lesson-accordion-list {
  display: grid;
  gap: 12px;
}

.lesson-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: white;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.lesson-accordion.open {
  border-color: #c7d2fe;
}

.lesson-accordion-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  text-align: right;
  background: var(--surface-soft);
  color: var(--gray-800);
  cursor: pointer;
}

.lesson-accordion.open .lesson-accordion-toggle {
  background: var(--primary-light);
}

.lesson-accordion-text strong,
.lesson-accordion-text span {
  display: block;
}

.lesson-accordion-text strong {
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.4;
}

.lesson-accordion-text span {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
  margin-top: 2px;
}

.lesson-accordion-status {
  color: var(--primary-dark);
  background: white;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-full);
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.lesson-accordion-body {
  padding: 14px;
  border-top: 1px solid var(--border);
  background: white;
}

/* ─── Collapsible lesson tree ───────────────────────────────── */
.lesson-tree {
  display: grid;
  gap: 10px;
}

.tree-unit {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: white;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tree-unit-open {
  border-color: #c7d2fe;
}

.tree-unit-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  text-align: right;
  background: var(--surface-soft);
  color: var(--gray-800);
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.tree-unit-open .tree-unit-toggle {
  background: #eef2ff;
}

.tree-unit-arrow {
  font-size: 0.7rem;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.tree-unit-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.4;
  text-align: right;
}

.tree-unit-badge {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 850;
  white-space: nowrap;
  color: var(--text-secondary);
}

.tree-unit-badge.has-topics {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
}

.tree-unit-body {
  border-top: 1px solid var(--border);
  padding: 8px;
  display: grid;
  gap: 6px;
  background: #fafafa;
}

.tree-lesson {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: white;
  overflow: hidden;
}

.tree-lesson-open {
  border-color: #a5b4fc;
}

.tree-lesson-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  text-align: right;
  background: transparent;
  color: var(--gray-800);
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.tree-lesson-open .tree-lesson-toggle {
  background: var(--primary-light);
}

.tree-lesson-title {
  font-size: 0.9rem;
  font-weight: 800;
  text-align: right;
}

.tree-lesson-arrow {
  color: var(--primary-dark);
  background: white;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.lesson-topic-status {
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.lesson-topic-status.has-topics {
  color: #16a34a;
  background: #dcfce7;
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

.tree-lesson-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: white;
}

.tree-topic-list {
  margin-bottom: 0;
}

.tree-topic-empty {
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 750;
  padding: 6px 0;
  margin: 0;
}

/* ─────────────────────────────────────────────────────────── */
.topic-picker-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: white;
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.topic-empty {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 750;
}

.topic-picker-stable {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lesson-picker-hint {
  margin: 0 0 4px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 750;
}

.topic-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.topic-tab {
  flex: 0 0 auto;
  min-width: 148px;
  max-width: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 10px 12px;
  text-align: right;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.topic-tab:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}

.topic-tab.active {
  border-color: #6366f1;
  background: var(--primary-light);
  box-shadow: 0 0 0 1px #6366f1;
}

.topic-tab-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  margin-left: 6px;
  border-radius: var(--radius-full);
  background: white;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 900;
  vertical-align: middle;
}

.topic-tab strong {
  display: block;
  color: var(--gray-800);
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.35;
  margin-top: 4px;
}

.topic-content-host {
  min-height: 280px;
}

.topic-content-host .topic-data-panel {
  margin: 0;
}

.topic-choice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.topic-choice {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 12px;
  text-align: right;
  cursor: pointer;
  transition: var(--transition);
}

.topic-choice:hover,
.topic-choice.active {
  border-color: #c7d2fe;
  background: var(--primary-light);
}

.topic-choice strong,
.topic-choice span {
  display: block;
}

.topic-choice strong {
  color: var(--gray-800);
  font-size: 0.94rem;
  font-weight: 900;
  line-height: 1.4;
}

.topic-choice span {
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 850;
  margin-top: 5px;
}

.topic-data-panel {
  grid-column: 1 / -1;
}

.topic-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.topic-text-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
}

.topic-text-panel.highlighted {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.topic-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: white;
}

.topic-panel-head span,
.topic-panel-head strong {
  font-size: 0.78rem;
  font-weight: 900;
}

.topic-panel-head span {
  color: var(--gray-700);
}

.topic-panel-head strong {
  color: var(--primary-dark);
  direction: ltr;
}

.topic-text-panel pre {
  margin: 0;
  padding: 12px;
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--gray-800);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.75;
}

.unit-list {
  display: grid;
  gap: 12px;
}

.unit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  overflow: hidden;
}

.unit-title {
  width: 100%;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
  background: transparent;
  cursor: pointer;
}

.unit-title-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.unit-title-stack {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: right;
}

.sidebar-catalog-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1.25;
}

.sidebar-chevron {
  flex-shrink: 0;
  width: 1rem;
  color: var(--primary-dark);
  font-size: 0.68rem;
  text-align: center;
}

.unit-lessons {
  display: grid;
}

.sidebar-lesson-group {
  border-bottom: 1px solid var(--border);
}

.sidebar-lesson-group:last-child {
  border-bottom: 0;
}

.sidebar-lesson-group.is-active-lesson {
  background: #fafbff;
}

.sidebar-lesson-head {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: stretch;
}

.sidebar-lesson-toggle {
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--primary-dark);
}

.sidebar-lesson-toggle:hover {
  background: white;
}

.sidebar-lesson-head .lesson-btn {
  border-bottom: 0;
}

.sidebar-topic-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 10px 38px;
  display: grid;
  gap: 4px;
}

.sidebar-topic-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: white;
  text-align: right;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-topic-btn:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}

.sidebar-topic-btn.active {
  border-color: #6366f1;
  background: var(--primary-light);
}

.sidebar-topic-btn.is-approved {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(236, 253, 245, 0.72);
}

.sidebar-topic-btn.is-approved.active {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.95), var(--primary-light));
}

.sidebar-topic-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.sidebar-topic-btn.is-approved .sidebar-topic-num {
  background: #d1fae5;
  color: #047857;
}

.sidebar-topic-title-wrap {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sidebar-topic-title {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.45;
  color: var(--gray-700);
}

.sidebar-topic-badge {
  font-size: 0.68rem;
  font-weight: 900;
  color: #047857;
  line-height: 1.3;
}

.sidebar-topic-empty {
  margin: 0;
  padding: 0 12px 10px 38px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 750;
}

.unit-title .unit-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: white;
  border: 1px solid var(--border);
  padding: 4px 7px;
  border-radius: var(--radius-full);
}

.lesson-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  text-align: right;
  background: transparent;
  border-bottom: 1px solid var(--border);
  color: var(--gray-700);
  transition: var(--transition);
}

.lesson-btn:last-child {
  border-bottom: 0;
}

.lesson-btn:hover {
  background: white;
}

.lesson-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.lesson-num {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--border);
  font-weight: 900;
  color: var(--gray-500);
}

.lesson-btn.active .lesson-num {
  border-color: #c7d2fe;
  color: var(--primary-dark);
}

.lesson-text strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 900;
}

.lesson-text span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 1px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.step-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  color: var(--gray-600);
}

.step-pill.clickable {
  cursor: pointer;
}

.step-pill.active {
  border-color: #c7d2fe;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.step-pill.done {
  background: var(--success-light);
  color: #166534;
  border-color: #bbf7d0;
}

.step-index {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--border);
  font-weight: 900;
  flex: 0 0 auto;
}

.step-pill strong {
  display: block;
  font-size: 0.88rem;
}

.step-pill span {
  display: block;
  font-size: 0.73rem;
  color: currentColor;
  opacity: .76;
  margin-top: 1px;
  font-weight: 700;
}

.workspace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  min-height: calc(100vh - var(--header-h) - 82px);
  overflow: hidden;
}

.screen-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.screen-header h2 {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 2px 0 6px;
}

.screen-header p {
  color: var(--text-secondary);
  font-weight: 700;
  max-width: 720px;
}

.screen-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.screen-body {
  padding: 24px 28px 28px;
}

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

.big-choice {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-soft);
  padding: 18px;
  min-height: 190px;
  text-align: right;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.big-choice:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: white;
}

.big-choice.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.big-choice .choice-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: white;
  font-size: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.big-choice h3 {
  font-size: 1rem;
  font-weight: 900;
  color: var(--gray-900);
}

.big-choice p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
}

.choice-footer {
  margin-top: auto;
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 0.82rem;
}

.plan-list {
  display: grid;
  gap: 12px;
  max-width: 880px;
}

.plan-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 13px;
  transition: var(--transition);
}

.plan-item:hover {
  background: white;
  box-shadow: var(--shadow-sm);
}

.plan-num {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 900;
}

.plan-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px 10px;
  background: transparent;
  color: var(--gray-800);
  font-weight: 850;
}

.plan-input:focus {
  outline: 0;
  border-color: #c7d2fe;
  background: white;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10);
}

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

.lesson-context-bar {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: white;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.lesson-context-bar .book-page-title {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.lesson-context-note {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
}

.block-workspace {
  display: grid;
  gap: 18px;
}

.block-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.block-editor {
  min-width: 0;
  background: var(--surface);
}

.block-editor .paragraph-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 100%;
}

.block-preview {
  border-right: 1px solid var(--border);
  background: white;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.block-preview-label {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-soft);
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--gray-800);
}

.block-preview-label small {
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.block-preview-canvas {
  padding: 16px;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.block-preview-canvas .preview-block {
  width: 100%;
  margin-bottom: 0;
}

.paragraph-list {
  display: grid;
  gap: 14px;
}

.paragraph-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.paragraph-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-soft);
}

.paragraph-title {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.paragraph-index {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.paragraph-title h3 {
  font-size: 1rem;
  font-weight: 900;
  margin-top: 1px;
}

.paragraph-title span {
  display: block;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.status-chip {
  border-radius: var(--radius-full);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  background: var(--warning-light);
  color: #92400e;
  white-space: nowrap;
}

.status-chip.approved {
  background: var(--success-light);
  color: #166534;
}

.status-chip.failed {
  background: #fee2e2;
  color: #991b1b;
}

.paragraph-body {
  padding: 18px;
}

.field-label {
  display: block;
  font-size: 0.79rem;
  font-weight: 900;
  color: var(--gray-600);
  margin-bottom: 7px;
}

.paragraph-textarea {
  width: 100%;
  min-height: 105px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 12px 13px;
  color: var(--gray-800);
  outline: 0;
}

.paragraph-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10);
}

.paragraph-toolbar {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.layout-select {
  min-width: 210px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: white;
  color: var(--gray-700);
  padding: 9px 11px;
  font-weight: 800;
  outline: 0;
}

.toolbar-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.collapsible {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  overflow: hidden;
  display: none;
}

.collapsible.open {
  display: block;
}

.collapsible-inner {
  padding: 13px;
  color: var(--gray-600);
  font-size: 0.86rem;
  font-weight: 700;
}

.collapsible textarea {
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 8px;
  outline: 0;
}

.source-pill {
  display: inline-flex;
  margin: 4px 0 4px 6px;
  padding: 6px 9px;
  border-radius: var(--radius-full);
  background: white;
  border: 1px solid var(--border);
  color: var(--gray-600);
  font-size: 0.78rem;
}

.preview-panel {
  position: sticky;
  top: 88px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview-panel-head {
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: white;
}

.preview-panel-head h3 {
  font-size: 0.98rem;
  font-weight: 900;
}

.preview-note {
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
}

.book-page {
  margin: 0 16px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  min-height: 460px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.book-page-title {
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.book-page-title small {
  color: var(--text-muted);
  font-weight: 800;
}

.book-page-title h2 {
  font-size: 1.18rem;
  font-weight: 900;
  color: var(--primary-dark);
}

.preview-block {
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 13px;
  margin-bottom: 12px;
  background: #fff;
}

.preview-block.simple {
  border-right: 5px solid var(--primary);
}

.preview-block.icon {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  background: var(--accent-light);
}

.preview-block.steps {
  background: var(--primary-light);
}

.preview-block.callout {
  background: var(--warning-light);
  border-color: #fde68a;
}

.preview-block h4 {
  font-size: 0.92rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.preview-block p {
  color: var(--gray-700);
  font-size: 0.86rem;
}

.preview-icon {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: white;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.preview-steps {
  counter-reset: step;
  display: grid;
  gap: 7px;
}

.preview-steps span {
  display: block;
  position: relative;
  padding-right: 28px;
  color: var(--gray-700);
  font-size: 0.85rem;
}

.preview-steps span::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  right: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: white;
  color: var(--primary-dark);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 900;
}

.empty-state {
  padding: 44px 20px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  color: var(--gray-800);
  font-size: 1.18rem;
  margin-bottom: 5px;
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.layout-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 13px;
  text-align: right;
  transition: var(--transition);
}

.layout-option:hover,
.layout-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.layout-thumb {
  height: 82px;
  border-radius: 14px;
  background: white;
  border: 1px dashed var(--gray-300);
  margin-bottom: 10px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.thumb-line {
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
}

.thumb-line.short {
  width: 64%;
}

.thumb-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-light);
}

.layout-option h4 {
  font-size: 0.9rem;
  font-weight: 900;
}

.layout-option p {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 3px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow: hidden;
  background: white;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
}

.modal.modal-wide {
  width: min(960px, 100%);
}

.full-lesson-preview {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.full-lesson-preview .book-page-title {
  margin-bottom: 16px;
}

.full-lesson-blocks {
  display: grid;
  gap: 12px;
}

.full-lesson-blocks>.component.preview-component {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.full-lesson-blocks table,
.full-lesson-blocks img {
  max-width: 100%;
}

.render-result-panel {
  display: grid;
  gap: 14px;
}

.result-success {
  font-weight: 900;
  color: var(--success-dark, #166534);
}

.result-helper-text {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.result-error {
  font-weight: 900;
  color: #991b1b;
}

.final-render-preview-frame {
  width: 100%;
  min-height: 85vh;
  border: 0;
  background: #fff;
}

.render-preview-loading,
.render-error-panel,
.template-dirty-warning {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 14px;
}

.generation-summary {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 12px 14px;
  font-weight: 900;
  color: var(--gray-700);
}

.generation-summary.has-failures,
.generation-error-box {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.generation-error-box {
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
  font-weight: 800;
}

.generation-error-box p {
  margin-top: 6px;
}

.generation-technical-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  padding: 10px 12px;
}

.generation-technical-details pre {
  margin-top: 8px;
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  max-height: 240px;
  overflow: auto;
}

.failed-preview .block-preview-canvas {
  align-items: stretch;
}

.template-dirty-warning {
  margin-bottom: 12px;
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
  font-weight: 800;
}

.error-details pre {
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  max-height: 260px;
  overflow: auto;
}

.dirty-block-list {
  margin: 8px 0 0;
  padding-right: 18px;
}

.result-meta-table {
  width: 100%;
  border-collapse: collapse;
  direction: ltr;
  text-align: left;
  font-size: 0.85rem;
}

.result-meta-table th,
.result-meta-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
}

.result-meta-table th {
  width: 44%;
  background: var(--surface-muted, #f8fafc);
}

.modal-header,
.modal-footer {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  justify-content: flex-start;
}

.modal-header h3 {
  font-size: 1.07rem;
  font-weight: 900;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.regen-modal-body {
  display: grid;
  gap: 14px;
}

.regen-template-summary,
.regen-current-content {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px 14px;
}

.regen-template-summary strong,
.regen-current-content strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.82rem;
}

.regen-template-summary span,
.regen-current-content p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.7;
}

.regen-instruction {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  line-height: 1.7;
}

.regen-instruction:focus {
  outline: 0;
  border-color: #c7d2fe;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10);
}


.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 34%, rgba(99, 102, 241, 0.20), transparent 34%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.40), rgba(15, 23, 42, 0.24));
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.processing-overlay.open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

body.processing-active .app-layout,
body.processing-active #appHeader {
  filter: blur(2px);
}

.processing-card {
  width: min(430px, 94vw);
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 28px 26px 24px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  text-align: center;
  animation: processingCardIn 0.22s ease-out;
}

.processing-orbit {
  width: 86px;
  height: 86px;
  position: relative;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    conic-gradient(from 0deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.60), rgba(99, 102, 241, 0.92), rgba(99, 102, 241, 0.08));
  animation: processingSpin 1.05s linear infinite;
  box-shadow: 0 14px 36px rgba(99, 102, 241, 0.25);
}

.processing-orbit::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.96);
}

.processing-core {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 10px rgba(99, 102, 241, 0.12), 0 0 28px rgba(6, 182, 212, 0.40);
  animation: processingPulse 1.15s ease-in-out infinite;
}

.processing-orbit-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  z-index: 2;
  background: #fff;
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.55);
}

.processing-orbit-dot.dot-a {
  top: 5px;
  right: 18px;
}

.processing-orbit-dot.dot-b {
  bottom: 9px;
  left: 15px;
  opacity: 0.82;
}

.processing-copy {
  display: grid;
  gap: 7px;
}

.processing-copy strong {
  font-size: 1.12rem;
  font-weight: 950;
  color: var(--gray-900);
}

.processing-copy p {
  color: var(--gray-700);
  font-weight: 850;
  line-height: 1.7;
}

.processing-copy small {
  color: var(--text-muted);
  font-weight: 800;
  line-height: 1.5;
}

@keyframes processingSpin {
  to { transform: rotate(360deg); }
}

@keyframes processingPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.78; }
  50% { transform: scale(1); opacity: 1; }
}

@keyframes processingCardIn {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .processing-orbit,
  .processing-core,
  .processing-card {
    animation: none;
  }
}

.toast-container {
  position: fixed;
  left: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 120;
}

.toast {
  background: var(--gray-900);
  color: white;
  border-radius: var(--radius-lg);
  padding: 11px 13px;
  box-shadow: var(--shadow-lg);
  font-weight: 850;
  min-width: 230px;
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }

  .book-sidebar {
    border-left: 0;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }

  .unit-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .block-row {
    grid-template-columns: 1fr;
  }

  .block-preview {
    border-right: 0;
    border-top: 1px solid var(--border);
  }

  .preview-panel {
    position: static;
  }

  .workspace-card {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  #appHeader {
    height: auto;
    min-height: var(--header-h);
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .header-center,
  .header-right {
    justify-content: flex-start;
  }

  .main-panel {
    padding: 14px;
  }

  .stepper,
  .choice-grid,
  .layout-grid,
  .unit-list {
    grid-template-columns: 1fr;
  }

  .topic-preview-grid {
    grid-template-columns: 1fr;
  }

  .screen-header {
    flex-direction: column;
    padding: 20px;
  }

  .screen-body {
    padding: 20px;
  }

  .paragraph-head,
  .paragraph-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .block-preview-canvas {
    padding: 14px;
  }

  .layout-select {
    width: 100%;
  }
}

/* ============================================================
   V3 additions: planning prompt + recommendations
   These are intentionally aligned with the V1 simplified style.
   ============================================================ */
.unit-title-button {
  width: 100%;
  background: var(--surface-soft);
  text-align: right;
  cursor: pointer;
}

.unit-title-button:hover {
  background: white;
  color: var(--primary-dark);
}

.unit-card.unit-open {
  border-color: #c7d2fe;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.08);
}

.selected-lesson-card {
  border: 1px solid #c7d2fe;
  background: linear-gradient(135deg, #ffffff, var(--primary-light));
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.selected-label {
  display: inline-flex;
  color: var(--primary-dark);
  background: white;
  border: 1px solid #c7d2fe;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 900;
  margin-bottom: 9px;
}

.selected-lesson-card h3 {
  font-size: 1.22rem;
  margin-bottom: 4px;
  font-weight: 900;
}

.selected-lesson-card p {
  color: var(--text-secondary);
  font-weight: 750;
}

.context-topic-name {
  margin-top: 4px;
  color: var(--primary-dark);
  font-size: 0.88rem;
  font-weight: 850;
}

.planning-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 340px;
  gap: 18px;
  margin-bottom: 20px;
}

.prompt-card,
.source-summary-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.planning-prompt {
  width: 100%;
  min-height: 190px;
  margin-top: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  line-height: 1.85;
  color: var(--gray-800);
  background: white;
  outline: none;
  transition: var(--transition);
}

.planning-prompt:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.prompt-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-summary-card h3 {
  font-size: 1rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.source-summary-card p {
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 720;
  margin-bottom: 12px;
}

.source-mini-list {
  display: grid;
  gap: 8px;
}

.source-mini-list span {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.83rem;
  font-weight: 850;
  color: var(--gray-700);
}

.compact-empty {
  padding: 26px 18px;
}

.recommendation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.recommendation-head h3 {
  font-size: 1.05rem;
  font-weight: 900;
}

.recommendation-head p {
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 740;
}

.recommendation-list {
  display: grid;
  gap: 10px;
}

.recommendation-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 250px;
  gap: 12px;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px;
  box-shadow: var(--shadow-sm);
}

.recommendation-num {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 900;
}

.recommendation-title-input {
  width: 100%;
  border: 1px solid transparent;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--gray-900);
  font-weight: 900;
  outline: none;
}

.recommendation-title-input:focus {
  border-color: var(--primary);
  background: white;
}

.recommendation-description {
  margin: 8px 0 0;
  color: var(--gray-700);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.6;
}

.template-scores-summary {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.5;
}

.recommendation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.recommendation-meta span {
  background: var(--gray-50);
  border: 1px solid var(--border);
  color: var(--gray-600);
  border-radius: var(--radius-full);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 850;
}

.recommendation-layout {
  display: grid;
  gap: 6px;
}

.recommendation-layout small {
  color: var(--text-secondary);
  font-weight: 800;
  font-size: 0.72rem;
}

.preview-block.comparison {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.comparison-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.comparison-preview-grid div {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.comparison-preview-grid strong {
  display: block;
  color: var(--primary-dark);
  font-size: 0.82rem;
  margin-bottom: 5px;
}

.comparison-preview-grid p {
  font-size: 0.8rem;
}

.layout-thumb-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.layout-thumb-comparison .thumb-line {
  width: auto;
}

@media (max-width: 1100px) {

  .planning-grid,
  .recommendation-card {
    grid-template-columns: 1fr;
  }

  .recommendation-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ============================================================
   Template-aware preview (aligned with clean_component_templates)
   ============================================================ */
.confidence-chip {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #c7d2fe;
  font-weight: 900;
}

.component.preview-component {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px 14px 14px;
  background: #fff;
  line-height: 1.7;
}

.component.preview-component h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--primary-dark);
}

.component.preview-component p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--gray-700);
}

.template-tag {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
}

.component.concept-definition {
  background: #f8fcfe;
  border-color: #b8e0ef;
}

.q-index {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.72rem;
  margin-left: 6px;
  flex-shrink: 0;
}

.mcq-question,
.tf-item,
.reason-item,
.answer-line-question {
  margin-top: 10px;
}

.question-stem,
.tf-statement,
.reason-prompt,
.question-prompt {
  display: block;
  font-size: 0.86rem;
  color: var(--gray-800);
  font-weight: 700;
}

.mcq-choices {
  margin: 8px 22px 0 0;
  padding-right: 18px;
  font-size: 0.84rem;
  color: var(--gray-700);
}

.tf-choice-boxes {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tf-choice-boxes span {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--gray-50);
}

.reason-space,
.answer-lines {
  min-height: 28px;
  margin-top: 8px;
  border-bottom: 1px dashed var(--gray-300);
}

.steps-list.preview-steps-list {
  margin: 10px 22px 0 0;
  padding-right: 18px;
  font-size: 0.85rem;
  color: var(--gray-700);
}

.component.activity-steps {
  background: var(--primary-light);
  border-color: #c7d2fe;
}

.component.unit-summary {
  background: var(--success-light);
  border-color: #bbf7d0;
}

.component.variant-cause-effect {
  background: #fff7ed;
  border-color: #fdba74;
}

.component.variant-cause-effect::after {
  content: "سبب ← نتيجة";
  display: block;
  margin-top: 10px;
  color: #9a3412;
  font-weight: 900;
  font-size: 0.76rem;
}

.component.variant-cycle {
  background: #f0fdf4;
  border-color: #86efac;
}

.component.variant-cycle::after {
  content: "دورة / تكرار";
  display: inline-block;
  margin-top: 10px;
  border: 1px dashed #16a34a;
  border-radius: 999px;
  padding: 4px 10px;
  color: #166534;
  font-weight: 900;
  font-size: 0.74rem;
}

.component.variant-flow {
  background: #eef2ff;
  border-color: #a5b4fc;
}

.component.variant-flow::after {
  content: "خطوات متسلسلة";
  display: block;
  margin-top: 10px;
  color: #3730a3;
  font-weight: 900;
  font-size: 0.76rem;
}

.component.variant-classification {
  background: #f8fafc;
  border-color: #94a3b8;
}

.component.variant-classification::after {
  content: "تصنيف";
  display: block;
  margin-top: 10px;
  color: #334155;
  font-weight: 900;
  font-size: 0.76rem;
}

.classification-chart-originalish {
  padding: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  border-color: #d6dbe1 !important;
  border-radius: 2px !important;
}

.classification-title {
  background: #078f49;
  color: #ffffff;
  font-weight: 900;
  font-size: 0.98rem;
  padding: 10px 14px;
  text-align: right;
}

.classification-root {
  background: #078f49;
  color: #ffffff;
  font-weight: 900;
  text-align: center;
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.classification-branches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 14px 16px 16px;
}

.classification-branch {
  min-height: 54px;
  border: 1px solid #07994b;
  background: #e9f8ee;
  padding: 10px 8px;
  text-align: center;
}

.classification-branch+.classification-branch {
  border-right: 0;
}

.classification-branch strong {
  display: block;
  color: #0f172a;
  font-size: 0.86rem;
  margin-bottom: 5px;
}

.classification-branch p {
  color: #334155;
  font-size: 0.74rem;
  line-height: 1.5;
}

.classification-note {
  border-top: 1px solid #d6dbe1;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 14px;
  text-align: left;
}

.experiment-details-originalish {
  padding: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  border-color: #c7d2de !important;
  border-radius: 2px !important;
  color: #0f172a;
}

.experiment-details-title {
  background: #155a80;
  color: #ffffff;
  font-weight: 900;
  text-align: center;
  padding: 16px 14px;
  border-bottom: 1px solid #d7e0ea;
}

.experiment-details-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  direction: rtl;
}

.experiment-details-table th {
  background: #155a80;
  color: #ffffff;
  font-weight: 900;
  text-align: center;
  padding: 12px 10px;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.22);
}

.experiment-details-table td {
  min-height: 74px;
  vertical-align: top;
  padding: 12px 12px;
  border: 1px solid #c7d2de;
  background: #ffffff;
  font-size: 0.84rem;
  line-height: 1.65;
}

.experiment-details-tools,
.experiment-details-steps {
  margin: 0;
  padding-inline-start: 18px;
}

.experiment-details-tools li,
.experiment-details-steps li {
  margin: 0 0 4px;
}

.guided-experiment-originalish {
  padding: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  border-color: #9ed9cc !important;
  border-radius: 0 !important;
  color: #111827;
  font-family: "Times New Roman", "Noto Naskh Arabic", serif;
}

.guided-experiment-header {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #08a97b;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
  text-align: right;
}

.guided-experiment-header span {
  flex: 1;
  border-bottom: 3px dotted rgba(255, 255, 255, 0.92);
  transform: translateY(3px);
}

.guided-experiment-objective {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  background: #e8fbef;
  border-inline: 1px solid #9ed9cc;
  border-bottom: 1px solid #9ed9cc;
  font-size: 0.96rem;
}

.guided-experiment-objective strong,
.guided-experiment-observation strong,
.guided-experiment-conclusion strong,
.guided-experiment-cell strong {
  font-weight: 900;
  color: #000000;
}

.guided-experiment-main {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(136px, 0.92fr);
  grid-template-areas: "diagram side";
  min-height: 190px;
  border-inline: 1px solid #9ed9cc;
}

.guided-experiment-side {
  grid-area: side;
  border-left: 1px solid #9ed9cc;
}

.guided-experiment-cell {
  min-height: 92px;
  padding: 12px 14px;
  background: #ffffff;
  font-size: 0.94rem;
  line-height: 1.55;
}

.guided-experiment-cell+.guided-experiment-cell {
  border-top: 1px solid #9ed9cc;
}

.guided-experiment-cell ul,
.guided-experiment-cell ol {
  margin: 12px 22px 0 0;
  padding: 0 16px 0 0;
}

.guided-experiment-cell li {
  margin: 0 0 2px;
}

.guided-experiment-diagram {
  grid-area: diagram;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
  min-height: 190px;
  background: #ffffff;
}

.guided-experiment-diagram span {
  width: 100%;
  min-height: 78px;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #9ca3af;
  color: #8b6f55;
  font-size: 0.95rem;
  font-weight: 900;
}

.guided-experiment-diagram img {
  max-width: 100%;
  max-height: 168px;
  object-fit: contain;
}

.guided-experiment-observation,
.guided-experiment-conclusion {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  min-height: 48px;
  padding: 9px 12px;
  border-inline: 1px solid #9ed9cc;
  border-top: 1px solid #9ed9cc;
  font-size: 0.96rem;
  line-height: 1.55;
}

.guided-experiment-observation {
  background: #fff8df;
}

.guided-experiment-conclusion {
  background: #bdd1ff;
}

.guided-experiment-observation span,
.guided-experiment-conclusion span,
.guided-experiment-objective span {
  flex: 1;
  border-bottom: 2px dotted #111827;
  min-height: 23px;
}

@media (max-width: 700px) {
  .classification-branches {
    grid-template-columns: 1fr;
  }

  .classification-branch+.classification-branch {
    border-right: 1px solid #07994b;
    border-top: 0;
  }

  .experiment-details-table {
    table-layout: auto;
  }

  .experiment-details-table th,
  .experiment-details-table td {
    padding: 10px 8px;
    font-size: 0.76rem;
  }

  .guided-experiment-main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "diagram"
      "side";
  }

  .guided-experiment-side {
    border-left: 0;
    border-top: 1px solid #9ed9cc;
  }
}

.component.variant-visual {
  background: #f0f9ff;
  border-color: #7dd3fc;
}

.component.variant-visual::before {
  content: "";
  display: block;
  height: 34px;
  margin: 2px 0 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, #bae6fd, #e0f2fe);
  border: 1px solid #7dd3fc;
}

.component.variant-experiment {
  background: #fefce8;
  border-color: #fde047;
}

.component.variant-question {
  background: #faf5ff;
  border-color: #d8b4fe;
}

.component.variant-comparison {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.component.variant-definition {
  background: #f8fcfe;
  border-color: #b8e0ef;
}

.example {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--gray-700);
}

/* Definition Structure Template Preview */
.def-structure-originalish {
  padding: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  border-color: #d6dbe1 !important;
  border-radius: 2px !important;
  color: #0f172a;
}

.def-structure-header {
  background: #64B55A;
  color: #ffffff;
  font-weight: 900;
  font-size: 1.02rem;
  padding: 10px 14px;
  text-align: right;
}

.def-structure-body {
  display: grid;
  grid-template-columns: 48% 52%;
  border: 1px solid #C9D6E2;
  border-top: none;
}

.def-structure-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-height: 120px;
  border-left: 1px solid #C9D6E2;
  background: #F7FAFC;
}

.def-structure-diagram span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 78px;
  border: 1.5px dashed #9AA7B2;
  color: #5C6670;
  font-weight: 900;
  font-size: 0.88rem;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
}

.def-structure-diagram img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
}

.def-structure-info {
  padding: 12px 14px;
}

.def-structure-definition {
  border-right: 4.5px solid #64B55A;
  padding: 8px 10px 8px 0;
  margin-bottom: 12px;
  background: #F6FFF7;
  font-size: 0.9rem;
  line-height: 1.7;
}

.def-structure-definition strong {
  color: #000;
  font-weight: 900;
}

.def-structure-definition span {
  color: #334155;
}

.def-structure-parts {
  display: grid;
  gap: 6px;
}

.def-structure-part {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.def-structure-part-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: #64B55A;
  color: #ffffff;
  font-weight: 900;
  font-size: 0.78rem;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
}

.def-structure-part-text {
  font-size: 0.86rem;
  color: #1e293b;
  line-height: 1.6;
}

@media (max-width: 700px) {
  .def-structure-body {
    grid-template-columns: 1fr;
  }

  .def-structure-diagram {
    border-left: none;
    border-bottom: 1px solid #C9D6E2;
  }
}

/* Biochemical Equation Explainer */
.eq-explainer-originalish {
  padding: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  border-color: #d6dbe1 !important;
  color: #0f172a;
}

.eq-explainer-header {
  background: #7B61B5;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
  text-align: right;
}

.eq-explainer-body {
  padding: 14px;
}

.eq-explainer-equation {
  background: #F5F1FF;
  border: 1px dashed #7B61B5;
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  margin-bottom: 10px;
}

.eq-explainer-reaction {
  font-size: 1.1rem;
  font-weight: 900;
  color: #000;
}

.eq-explainer-conditions {
  margin-top: 6px;
  font-size: 0.82rem;
  color: #7B61B5;
  font-weight: 800;
}

.eq-explainer-explanation {
  background: #F6FFF7;
  border-right: 4px solid #64B55A;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.6;
}

/* Element Description Table */
.element-desc-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.element-desc-header {
  background: #1F4E79;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.element-desc-table {
  width: 100%;
  border-collapse: collapse;
}

.element-desc-table th {
  background: #EAF3F8;
  color: #1F4E79;
  font-weight: 900;
  padding: 8px 10px;
  text-align: right;
  border: 1px solid #d6dbe1;
}

.element-desc-table td {
  padding: 8px 10px;
  border: 1px solid #d6dbe1;
  font-size: 0.86rem;
}

/* Worked Example */
.worked-example-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #fca5a5 !important;
}

.worked-example-header {
  background: #D71920;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.worked-example-problem {
  padding: 12px 14px;
  background: #fff0f0;
  font-size: 0.9rem;
  border-bottom: 1px dashed #fca5a5;
}

.worked-example-solution-header {
  padding: 10px 14px 0;
  font-weight: 900;
  color: #1F4E79;
}

.worked-example-solution {
  padding: 10px 14px 14px;
}

.worked-example-steps {
  margin: 0 20px 0 0;
  padding: 0;
  font-size: 0.86rem;
}

.worked-example-answer {
  margin-top: 10px;
  padding: 8px 12px;
  background: #E8F6E9;
  border-right: 4px solid #64B55A;
  font-size: 0.9rem;
}

/* Mechanism Two Stage */
.mechanism-two-stage-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #fdba74 !important;
}

.mechanism-header {
  background: #F2994A;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.mechanism-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mechanism-stage {
  border: 1px solid #fed7aa;
  padding: 10px;
  border-radius: 6px;
}

.mechanism-stage.stage-1 {
  background: #FFF8F0;
}

.mechanism-stage.stage-2 {
  background: #F8FBFF;
  border-color: #bfdbfe;
}

.mechanism-stage-title {
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.mechanism-stage-desc {
  font-size: 0.84rem;
  color: #334155;
}

.mechanism-arrow {
  text-align: center;
  font-size: 1.4rem;
  color: #F2994A;
  line-height: 1;
}

/* Metabolism Dual Concept */
.dual-concept-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #94a3b8 !important;
}

.dual-concept-header {
  background: #244A6B;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.dual-concept-body {
  padding: 14px;
}

.dual-concept-central {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 10px;
  text-align: center;
  font-weight: 900;
  margin-bottom: 14px;
  border-radius: 6px;
}

.dual-concept-branches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dual-concept-branch {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #d6dbe1;
}

.dual-concept-branch.branch-1 {
  background: #F6FFF7;
  border-color: #86efac;
}

.dual-concept-branch.branch-2 {
  background: #FFF8F0;
  border-color: #fdba74;
}

.dual-concept-branch-title {
  font-weight: 900;
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.dual-concept-branch-desc {
  font-size: 0.82rem;
}

/* Factors Affecting */
.factors-affecting-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #86efac !important;
}

.factors-header {
  background: #008A45;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.factors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.factor-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 8px;
  border-radius: 6px;
}

.factor-num {
  width: 20px;
  height: 20px;
  background: #008A45;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  flex-shrink: 0;
}

.factor-info strong {
  display: block;
  font-size: 0.86rem;
  color: #0f172a;
}

.factor-info span {
  font-size: 0.8rem;
  color: #475569;
}

/* Gallery Images */
.gallery-images-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.gallery-header {
  background: #1F4E79;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.gallery-item {
  border: 1px solid #d6dbe1;
  border-radius: 6px;
  overflow: hidden;
  background: #f8fafc;
}

.gallery-img-placeholder {
  background: #e2e8f0;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.8rem;
}

.gallery-img-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-caption {
  padding: 8px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: bold;
  background: #F7FAFC;
}

/* Experiment Steps Images */
.exp-steps-images-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.exp-steps-header {
  background: #1F4E79;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.exp-steps-list {
  padding: 14px;
}

.exp-step-item {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 10px;
  background: #F7FAFC;
  border: 1px solid #EAF3F8;
  border-radius: 6px;
  overflow: hidden;
}

.exp-step-item:last-child {
  margin-bottom: 0;
}

.exp-step-num {
  background: #1F4E79;
  color: #fff;
  padding: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  flex-shrink: 0;
}

.exp-step-text {
  flex-grow: 1;
  padding: 10px;
  font-size: 0.88rem;
}

.exp-step-img {
  width: 80px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.exp-step-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Data Recording Table */
.data-table-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.data-table-header {
  background: #0B9ED8;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.data-table-wrapper {
  padding: 14px;
}

.data-record-table {
  width: 100%;
  border-collapse: collapse;
}

.data-record-table th {
  background: #F6FBFF;
  color: #0B9ED8;
  font-weight: 900;
  padding: 8px 10px;
  border: 1px solid #cce9f8;
  text-align: center;
}

.data-record-table td {
  padding: 8px 10px;
  border: 1px solid #cce9f8;
  text-align: center;
  font-size: 0.86rem;
  background: #fff;
}

/* Sequence Stages */
.seq-stages-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.seq-stages-header {
  background: #1D75BD;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.seq-stages-list {
  padding: 14px;
}

.seq-stage-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.seq-stage-item:last-child {
  margin-bottom: 0;
}

.seq-stage-img {
  height: 80px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.seq-stage-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.seq-stage-text {
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #EEEEEE;
}

.seq-stage-num {
  background: #1D75BD;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.seq-stage-text p {
  margin: 0;
  font-size: 0.86rem;
}

/* Annotated Diagram */
.annotated-diagram-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.annotated-header {
  background: #1D75BD;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.annotated-body {
  padding: 14px;
}

.annotated-img {
  height: 120px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: 6px;
  margin-bottom: 14px;
}

.annotated-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.annotated-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.annotated-label {
  background: #EEEEEE;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  border: 1px solid #d6dbe1;
  color: #334155;
  font-weight: bold;
}

/* Arrow Connector */
.arrow-connector-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #d6dbe1 !important;
}

.arrow-conn-header {
  background: #1D75BD;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
}

.arrow-conn-body {
  padding: 20px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.arrow-conn-item {
  background: #f8fafc;
  border: 2px solid #1D75BD;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 900;
  color: #0f172a;
  text-align: center;
  flex: 1;
}

.arrow-conn-icon {
  font-size: 1.8rem;
  color: #1D75BD;
  font-weight: 900;
}

/* Process Distinction */
.proc-distinction-originalish {
  padding: 0 !important;
  overflow: hidden;
  border-color: #f87171 !important;
}

.proc-distinction-header {
  background: #D65A4A;
  color: #ffffff;
  font-weight: 900;
  padding: 10px 14px;
  text-align: center;
}

.proc-distinction-body {
  display: flex;
  align-items: stretch;
  background: #FFF8D8;
}

.proc-distinction-col {
  flex: 1;
  padding: 14px;
  text-align: center;
}

.proc-distinction-col.proc-a {
  background: #FFF1EF;
}

.proc-distinction-col.proc-b {
  background: #F1F6FB;
}

.proc-distinction-title {
  font-weight: 900;
  color: #D65A4A;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.proc-distinction-desc {
  font-size: 0.86rem;
  color: #334155;
}

.proc-distinction-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #D65A4A;
  color: #fff;
  font-weight: 900;
  padding: 0 10px;
  font-size: 1.2rem;
}

/* Callout Boxes (Phase 4) */
.callout-box {
  padding: 0 !important;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 14px;
}

.callout-header {
  color: #fff;
  font-weight: 900;
  padding: 8px 12px;
}

.callout-body {
  padding: 12px;
  border-width: 0 1px 1px 1px;
  border-style: solid;
}

.callout-body p {
  margin: 0;
  font-size: 0.9rem;
}

.callout-body ul {
  margin: 8px 0 0 20px;
  padding: 0;
  font-size: 0.86rem;
}

.bg-yellow-remember {
  background: #F29E38;
}

.border-yellow-remember {
  border-color: #F29E38;
  background: #FFF8D8;
}

.bg-blue-side {
  background: #1D75BD;
}

.border-blue-side {
  border-color: #1D75BD;
  background: #EAF3F8;
}

.bg-green-tech {
  background: #64B55A;
}

.border-green-tech {
  border-color: #64B55A;
  background: #F6FFF7;
}

.bg-orange-real {
  background: #F2994A;
}

.border-orange-real {
  border-color: #F2994A;
  background: #FFF8F0;
}

.bg-purple-discuss {
  background: #7B61A8;
}

.border-purple-discuss {
  border-color: #7B61A8;
  background: #F5F1FF;
}

/* MCQ Originalish Template */
.mcq-originalish {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

.mcq-orig-box {
  background: #FFF8DF;
  border: 2px solid #F2B134;
  padding: 12px;
  direction: rtl;
}

.mcq-orig-tag-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.mcq-orig-tag {
  background: #D14C00;
  color: white;
  font-weight: 900;
  font-size: 1rem;
  padding: 4px 14px;
}

.mcq-orig-intro {
  font-weight: 900;
  font-size: 0.95rem;
  color: #111;
  margin-bottom: 6px;
}

.mcq-orig-q-text {
  font-size: 0.9rem;
  color: #111;
  margin-bottom: 10px;
}

.mcq-orig-table {
  width: 100%;
  background: white;
  border-collapse: collapse;
}

.mcq-orig-table td {
  border: 1px solid #E5C36C;
  padding: 6px 8px;
}

.mcq-orig-td-choice {
  text-align: right;
  font-size: 0.9rem;
}

.mcq-orig-td-letter {
  width: 32px;
  text-align: center;
  font-weight: 900;
  font-size: 0.95rem;
}

.mcq-orig-td-check {
  width: 32px;
  text-align: center;
  font-size: 1.2rem;
}


/* V7 backend block preview parity */
.block-render-preview-frame {
  width: 100%;
  min-height: 460px;
  border: 0;
  background: #fff;
  border-radius: 12px;
}

.comparison-table-wrap {
  overflow-x: auto;
}

.comparison-criteria-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.comparison-criteria-table th {
  background: var(--blue, #0b77a5);
  color: #fff;
  padding: 10px;
  text-align: center;
}

.comparison-criteria-table td {
  border: 1px solid var(--line, #d8e4ea);
  padding: 10px;
  vertical-align: top;
}

.comparison-criteria-table .criterion-cell {
  font-weight: 900;
  color: var(--blue, #0b77a5);
  width: 28%;
}

.comparison-intro {
  margin: 0 0 10px;
  color: var(--gray-700, #374151);
  font-weight: 700;
}

/* ============================================================
   V10 Template Shape Previews for SME template selection
   ============================================================ */
.modal.modal-wide {
  width: min(1080px, 100%);
}

.template-picker-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}

.template-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-height: 68vh;
  overflow: auto;
  padding-inline-end: 4px;
}

.template-preview-option {
  min-height: 222px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-preview-option .tpl-shape {
  flex: 1;
}

.template-preview-panel {
  position: sticky;
  top: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.template-detail-meta {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.template-detail-meta span {
  font-weight: 950;
  color: var(--gray-900);
}

.template-detail-meta small {
  color: var(--text-secondary);
  font-weight: 800;
  direction: ltr;
  text-align: right;
}

.template-detail-best-for {
  margin: 10px 0 0;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  font-weight: 750;
}

.template-family-chip {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: var(--gray-50);
  color: var(--gray-600);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 900;
}

.recommendation-template-preview {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 8px;
  overflow: hidden;
  height: 260px;
  display: flex;
  flex-direction: column;
}

.tpl-ref-preview {
  direction: ltr;
  width: 100%;
  background: #fff;
  border: 1.5px solid #dbe7ef;
  border-radius: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto; /* Enable interaction */
}

/* Toolbar overlay */
.tpl-ref-preview-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 8px;
}

.tpl-zoom-btn {
  background: transparent;
  border: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  cursor: pointer;
  color: #334155;
  transition: background 0.15s, color 0.15s;
}

.tpl-zoom-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.tpl-zoom-btn svg {
  width: 15px;
  height: 15px;
}

.tpl-ref-preview-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto;
  position: relative;
}

.tpl-ref-preview-scale-wrapper {
  position: relative;
  transform-origin: top left;
}

.tpl-ref-preview-stage {
  direction: rtl;
  width: 794px;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

.tpl-ref-preview .raw-reference-template,
.tpl-ref-preview section {
  display: block;
  direction: rtl;
  width: 100%;
  max-width: none;
  overflow: visible;
  margin: 0;
}

.tpl-ref-preview .WordSection1,
.tpl-ref-preview div[align] {
  width: 100%;
}

.tpl-ref-preview table {
  width: 100% !important;
  max-width: 100%;
  margin-inline: auto;
}

.tpl-ref-preview-thumb {
  height: 120px;
}

.tpl-ref-preview-recommendation {
  flex: 1;
  height: 100%;
}

.tpl-ref-preview-detail {
  height: 400px;
}

.template-preview-option .tpl-ref-preview {
  height: 120px;
}

.template-preview-panel .tpl-ref-preview-detail {
  height: 420px;
}

.tpl-shape {
  direction: rtl;
  text-align: right;
  background: #fff;
  border: 1.5px solid #dbe7ef;
  border-radius: 14px;
  padding: 10px;
  color: #172033;
  overflow: hidden;
  min-height: 108px;
  font-size: 0.74rem;
  line-height: 1.45;
}

.tpl-shape-thumb {
  min-height: 108px;
}

.tpl-shape-recommendation {
  min-height: 94px;
  padding: 8px;
  font-size: 0.68rem;
}

.tpl-shape-detail {
  min-height: 210px;
  padding: 14px;
  font-size: 0.86rem;
}

.tpl-shape-title {
  font-weight: 950;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.tpl-shape h5 {
  margin: 6px 0;
  font-weight: 950;
  color: #0f172a;
}

.tpl-shape p {
  margin: 5px 0;
  color: #334155;
}

.tpl-shape ul,
.tpl-shape ol {
  margin: 5px 18px 0 0;
  padding: 0 14px 0 0;
}

.tpl-shape li {
  margin: 2px 0;
}

.tpl-pill,
.tpl-tag-mini {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #cdeef7;
  color: #0b77a5;
  font-weight: 950;
  padding: 3px 9px;
  margin-bottom: 6px;
}

.tpl-row {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 6px;
  border: 1px solid #e4edf3;
  border-radius: 8px;
  padding: 6px;
  margin-top: 5px;
  background: #fbfdff;
}

.tpl-row b {
  color: #0b77a5;
}

.tpl-exp-head {
  background: #08a97b;
  color: #fff;
  padding: 6px 8px;
  font-weight: 950;
  border-radius: 8px 8px 0 0;
}

.tpl-exp-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  border-inline: 1px solid #9ed9cc;
  min-height: 45px;
}

.tpl-exp-grid>div {
  padding: 7px;
  border-inline-start: 1px solid #9ed9cc;
}

.tpl-exp-grid span,
.tpl-question span,
.tpl-flow-lines i {
  display: block;
  height: 7px;
  margin-top: 6px;
  border-radius: 999px;
  background: #d6dbe1;
}

.tpl-exp-strip {
  background: #fff8df;
  border: 1px solid #9ed9cc;
  border-top: 0;
  padding: 5px 7px;
  font-weight: 900;
}

.tpl-exp-strip.blue {
  background: #dce7ff;
}

.tpl-shape-comparison table,
.tpl-shape-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.66rem;
}

.tpl-shape-comparison th,
.tpl-shape-table th {
  background: #0b77a5;
  color: #fff;
  padding: 5px;
}

.tpl-shape-comparison td,
.tpl-shape-table td {
  border: 1px solid #d8e4ea;
  padding: 5px;
  min-height: 18px;
}

.tpl-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 15px 0 6px;
}

.tpl-flow span {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 999px;
  background: #0ea5c7;
  color: #fff;
  font-weight: 950;
}

.tpl-flow-lines {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-inline: 16px;
}

.tpl-class-root {
  background: #078f49;
  color: #fff;
  padding: 8px;
  text-align: center;
  font-weight: 950;
  border-radius: 10px 10px 0 0;
}

.tpl-class-branches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.tpl-class-branches span {
  border: 1px solid #07994b;
  background: #e9f8ee;
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  font-weight: 850;
}

.tpl-visual-box {
  min-height: 74px;
  display: grid;
  place-items: center;
  border: 1.5px dashed #9ca3af;
  background: #f8fafc;
  border-radius: 10px;
  color: #64748b;
  font-weight: 900;
}

.tpl-question {
  border: 1px solid #d8e4ea;
  border-radius: 10px;
  padding: 8px;
  background: #faf5ff;
}

.tpl-def-head {
  background: #64B55A;
  color: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 950;
}

.tpl-shape-learning {
  background: #f8fcfe;
  border-color: #b8e0ef;
}

.tpl-shape-glossary {
  background: #fbfdff;
  border-color: #dbe7ef;
}

.tpl-shape-experiment {
  background: #fffefa;
  border-color: #9ed9cc;
}

.tpl-shape-comparison {
  background: #f8fafc;
  border-color: #9ccfe0;
}

.tpl-shape-process {
  background: #f1fbff;
  border-color: #9ccfe0;
}

.tpl-shape-classification {
  background: #f7fff9;
  border-color: #86efac;
}

.tpl-shape-question {
  background: #faf5ff;
  border-color: #d8b4fe;
}

.tpl-shape-definition {
  background: #f8fff8;
  border-color: #bbf7d0;
}

@media (max-width: 980px) {
  .template-picker-shell {
    grid-template-columns: 1fr;
  }

  .template-preview-panel {
    position: static;
  }

  .template-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .template-picker-grid {
    grid-template-columns: 1fr;
  }
}

/* V10: give recommendation preview column enough space */
.recommendation-card {
  grid-template-columns: 42px minmax(0, 1fr) minmax(320px, 400px);
}

.recommendation-layout .layout-select {
  min-width: 0;
}

/* ============================================================
   V12 SME-friendly compact backend previews and regeneration dialog
   ============================================================ */
.block-row {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
}

.block-preview {
  min-height: 0;
}

.block-preview-canvas {
  height: 420px;
  overflow: hidden;
  padding: 0;
  position: relative;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
}

.block-render-preview-frame {
  display: block;
  width: 100%;
  min-height: 280px;
  height: 400px;
  transform: none;
  border: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10);
  overflow: hidden;
}

.block-preview-label {
  padding: 10px 12px;
}

.block-preview-label span {
  font-size: 0.8rem;
}

.block-preview-label small {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sme-regen-modal {
  gap: 12px;
}

.regen-help-box {
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  border-radius: 14px;
  padding: 12px 14px;
  color: #0f172a;
}

.regen-help-box strong {
  display: block;
  margin-bottom: 5px;
  color: #0369a1;
  font-size: 0.88rem;
}

.regen-help-box p {
  margin: 0;
  line-height: 1.75;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 750;
}

.sme-natural-instruction {
  min-height: 150px;
  font-size: 0.95rem;
}

.regen-current-content summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 8px;
}

.regen-readable-content {
  white-space: pre-wrap;
  line-height: 1.85;
  color: var(--text-secondary);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  max-height: 220px;
  overflow: auto;
  font-size: 0.88rem;
}

.regen-template-summary span small {
  display: inline-block;
  margin-inline-start: 6px;
  color: var(--text-secondary);
  direction: ltr;
}

@media (max-width: 980px) {
  .block-row {
    grid-template-columns: 1fr;
  }

  .block-preview-canvas {
    height: 240px;
    min-height: 240px;
  }
}

/* V13 opening book selection + Arabic SME-facing wording */
.curriculum-start-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 26px;
  box-shadow: var(--shadow-sm);
}

.curriculum-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 22px 24px;
  direction: rtl;
}

.curriculum-field {
  display: grid;
  gap: 10px;
}

.curriculum-field span {
  font-weight: 900;
  color: var(--text-primary);
  font-size: 1rem;
  text-align: right;
}

.curriculum-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 800;
  min-height: 60px;
  padding: 0 18px;
  outline: none;
}

.curriculum-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.curriculum-summary-card {
  margin-top: 22px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-secondary);
  font-weight: 800;
}

.curriculum-summary-card strong {
  color: var(--text-primary);
}

.curriculum-actions {
  justify-content: flex-start;
  margin-top: 22px;
}

.opening-header h2 {
  font-size: 1.7rem;
}

@media (max-width: 850px) {
  .curriculum-grid {
    grid-template-columns: 1fr;
  }

  .curriculum-summary-card {
    flex-direction: column;
  }
}

/* V20: topic scan status labels for SME lesson catalog */
.lesson-topic-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.topic-scan-summary {
  display: inline-flex;
  margin-top: 8px;
  color: #059669;
  font-weight: 800;
}
/* V27: Topic rephrased source preview + AI rewrite modal */
.topic-panel-head-actions {
  align-items: center;
}

.topic-preview-action {
  border: 1px solid #bfdbfe;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  color: #1d4ed8;
  border-radius: 999px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(59, 130, 246, 0.12);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.topic-preview-action:hover,
.topic-preview-action:focus-visible {
  transform: translateY(-1px);
  border-color: #60a5fa;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
  outline: none;
}

.topic-preview-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.modal.topic-rephrase-wide {
  width: min(1120px, 96vw);
}

.topic-rephrase-modal {
  display: grid;
  gap: 16px;
}

.topic-rephrase-preview-card {
  border: 1px solid #c7d2fe;
  border-radius: 18px;
  overflow: hidden;
  background: #f8fafc;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.topic-rephrase-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #dbeafe;
  background: linear-gradient(135deg, #eef2ff, #ecfeff);
}

.topic-rephrase-card-head span,
.topic-rephrase-card-head strong {
  font-size: 0.86rem;
  font-weight: 900;
}

.topic-rephrase-card-head span {
  color: #475569;
}

.topic-rephrase-card-head strong {
  color: #1d4ed8;
}

#topicRephrasedPreviewText {
  margin: 0;
  padding: 18px;
  min-height: 380px;
  max-height: 54vh;
  overflow: auto;
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  color: #1e293b;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 750;
  line-height: 1.95;
  background: #ffffff;
}

.topic-rephrase-request {
  display: grid;
  gap: 8px;
}

.topic-rephrase-request span {
  font-weight: 900;
  color: #334155;
}

.topic-rephrase-request textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 13px 14px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.7;
  color: #0f172a;
  background: #f8fafc;
}

.topic-rephrase-request textarea:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
  background: #ffffff;
}

.topic-rephrase-note,
.topic-rephrase-error {
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 850;
  line-height: 1.7;
}

.topic-rephrase-note {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.topic-rephrase-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

@media (max-width: 900px) {
  .topic-preview-grid {
    grid-template-columns: 1fr;
  }

  .topic-rephrase-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  #topicRephrasedPreviewText {
    min-height: 280px;
  }
}

/* V31: SME manual plan editing */
.manual-plan-head {
  align-items: flex-start;
}

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

.plan-count-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 950;
}

.recommendation-card {
  grid-template-columns: 54px minmax(0, 1fr) minmax(320px, 400px);
  align-items: start;
}

.recommendation-num-wrap {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.recommendation-order-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--gray-700);
  font-weight: 950;
  cursor: pointer;
}

.mini-icon-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-light);
}

.mini-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.recommendation-toolbar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.btn-danger-soft {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.btn-danger-soft:hover {
  background: #ffe4e6;
  border-color: #fca5a5;
}

.recommendation-description-input {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 9px 11px;
  color: var(--gray-800);
  font-weight: 750;
  line-height: 1.65;
  outline: none;
  resize: vertical;
  min-height: 82px;
}

.recommendation-description-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63, 99, 243, 0.12);
}

.manual-plan-select-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.manual-plan-select-row label,
.manual-plan-field {
  display: grid;
  gap: 5px;
  color: var(--gray-700);
  font-size: 0.78rem;
  font-weight: 900;
}

.manual-plan-select-row select,
.manual-plan-field input,
.manual-plan-field select,
.manual-plan-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--gray-900);
  padding: 9px 10px;
  font-weight: 800;
  outline: none;
}

.manual-plan-field textarea {
  resize: vertical;
  line-height: 1.75;
}

.manual-plan-select-row select:focus,
.manual-plan-field input:focus,
.manual-plan-field select:focus,
.manual-plan-field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63, 99, 243, 0.12);
}

.manual-plan-modal {
  padding: 4px;
}

.manual-plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
  align-items: start;
}

.manual-plan-description-field {
  grid-column: 1 / 2;
}

.manual-plan-preview {
  grid-column: 2 / 3;
  grid-row: 1 / span 5;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 10px;
  position: sticky;
  top: 0;
  min-height: 340px;
}

.manual-plan-preview small {
  display: block;
  margin-top: 8px;
  color: var(--text-secondary);
  font-weight: 850;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .recommendation-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .recommendation-layout {
    grid-column: 1 / -1;
  }

  .manual-plan-grid,
  .manual-plan-select-row {
    grid-template-columns: 1fr;
  }

  .manual-plan-preview,
  .manual-plan-description-field {
    grid-column: auto;
    grid-row: auto;
    position: static;
  }
}

/* Lesson topic approval checklist */
.lesson-topic-checklist {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 14px;
  margin: 0 0 18px;
  box-shadow: var(--shadow-sm);
}

.lesson-topic-checklist.ready {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(135deg, #ffffff, rgba(220, 252, 231, 0.55));
}

.checklist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.checklist-head strong,
.checklist-head span {
  display: block;
}

.checklist-head strong {
  color: var(--gray-900);
  font-size: 1rem;
  font-weight: 950;
}

.checklist-head span {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.84rem;
  font-weight: 800;
}

.topic-checklist-list {
  display: grid;
  gap: 8px;
}

.topic-checklist-row {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: right;
  cursor: pointer;
  transition: var(--transition);
}

.topic-checklist-row:hover,
.topic-checklist-row.active {
  border-color: #c7d2fe;
  background: var(--primary-light);
}

.topic-checklist-row.approved {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(236, 253, 245, 0.92);
}

.topic-check-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-weight: 950;
}

.topic-checklist-row.approved .topic-check-icon {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.topic-check-title {
  color: var(--gray-900);
  font-weight: 950;
  line-height: 1.5;
}

.topic-check-status {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.topic-checklist-row.approved .topic-check-status {
  color: #166534;
}

.checklist-note {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 850;
}

.checklist-note.success {
  color: #166534;
}

@media (max-width: 760px) {
  .checklist-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topic-checklist-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .topic-check-status {
    grid-column: 2 / 3;
  }
}

/* V38: ultra-compact lesson approval controls inside the sidebar only */
.sidebar-lesson-approval {
  margin: -2px 14px 8px;
  padding: 6px 8px 7px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 5px;
}

.sidebar-lesson-approval.has-approved {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(236, 253, 245, 0.45);
}

.sidebar-lesson-approval.complete {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(236, 253, 245, 0.72);
}

.sidebar-approval-compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}

.sidebar-approval-count {
  direction: ltr;
  font-size: 0.78rem;
  font-weight: 950;
  color: var(--primary-dark);
  white-space: nowrap;
}

.sidebar-approval-label {
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: right;
  line-height: 1.2;
}

.sidebar-approval-track {
  height: 4px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.sidebar-approval-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.25s ease;
}

.sidebar-render-lesson-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--success);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 950;
  text-align: center;
  padding: 2px 0 0;
}

.sidebar-render-lesson-link:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* V42: clean RTL render result actions */
.render-result-rtl,
.approved-render-inline-preview {
  direction: rtl;
  text-align: right;
}

.approved-render-inline-preview {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
}

.approved-render-inline-preview > strong {
  display: block;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 950;
  text-align: right;
}

.approved-render-inline-preview > p {
  margin: 4px 0 12px;
  color: var(--text-secondary);
  font-weight: 700;
  text-align: right;
}

.final-render-preview-frame {
  direction: rtl;
}

.render-result-actions {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.render-result-actions .btn {
  min-height: 52px;
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 0.94rem;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.btn-with-icon .btn-icon-svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.render-result-actions .btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.render-result-actions .btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

@media (max-width: 640px) {
  .render-result-actions .btn {
    width: 100%;
  }
}

/* -------------------------------------------------------------------------- */
/* StorySpark authoring shell                                                 */
/* -------------------------------------------------------------------------- */
.ss-page {
  display: grid;
  gap: 18px;
  text-align: right;
  direction: rtl;
}
.ss-page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: flex-start;
}
.ss-page-header h2 {
  margin: 0;
  font-size: 1.35rem;
}
.ss-page-header .btn-ghost {
  margin-inline-start: auto;
}
.ss-builder-header {
  align-items: flex-start;
}
.ss-builder-title {
  flex: 1 1 220px;
  min-width: 0;
  text-align: right;
}
.ss-builder-title h2 {
  margin: 0 0 4px;
}
.ss-builder-title p {
  width: auto;
}
.ss-builder-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}
.ss-builder-header > .btn-ghost {
  margin-inline-start: 0;
}
.ss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.ss-card,
.ss-template-card,
.ss-lesson-row,
.ss-screen-card {
  border: 1px solid #dbe3ee;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: right;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  cursor: pointer;
}
.ss-template-card strong {
  display: block;
  margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  direction: ltr;
  text-align: left;
}
.ss-card span,
.ss-template-card span {
  color: #64748b;
  font-size: 0.9rem;
}
.ss-card:hover,
.ss-template-card:hover,
.ss-lesson-row:hover {
  border-color: #7dd3fc;
}
.ss-template-card.selected {
  border-color: #0284c7;
  background: #f0f9ff;
}
.ss-empty,
.ss-empty-builder {
  color: #64748b;
  padding: 28px;
  text-align: center;
}
.ss-unit-panel {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #f8fafc;
}
.ss-unit-panel > header {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.ss-unit-panel > header h3 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}
.ss-unit-panel > header .ss-unit-export {
  flex: 0 0 auto;
  margin-inline-start: auto;
}
.ss-lesson-list {
  display: grid;
  gap: 8px;
}
.ss-unit-panel > header .ss-unit-chip {
  flex: 0 0 auto;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}
.ss-lesson-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  text-align: right;
}
.ss-lesson-row strong {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}
.ss-lesson-row .ss-lesson-meta {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 0.82rem;
  white-space: nowrap;
}
.ss-lesson-status {
  flex: 0 0 auto;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}
.ss-lesson-status-approved {
  background: #dcfce7;
  color: #166534;
}
.ss-lesson-status-pending {
  background: #ffedd5;
  color: #9a3412;
}
.ss-lesson-status-ready {
  background: #e0f2fe;
  color: #075985;
}
.ss-lesson-status-progress {
  background: #ede9fe;
  color: #5b21b6;
}
.ss-lesson-status-todo {
  background: #f1f5f9;
  color: #64748b;
}
.ss-lesson-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  text-align: right;
  margin-bottom: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.ss-lesson-btn-title {
  flex: 1 1 auto;
  min-width: 0;
}
.ss-unit-summary {
  font-size: 0.75rem;
  color: #64748b;
  margin: -4px 0 8px;
}
.ss-page-header p {
  margin: 0;
  color: #475569;
  width: 100%;
  text-align: right;
}
.ss-screen-list {
  display: grid;
  gap: 12px;
}
.ss-screen-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.ss-screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  justify-content: flex-start;
}
.ss-screen-actions button {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}
.ss-status {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
}
.ss-status-generated,
.ss-status-ready {
  background: #dcfce7;
  color: #166534;
}
.ss-status-error {
  background: #fee2e2;
  color: #991b1b;
}
.ss-status-generating {
  background: #ffedd5;
  color: #9a3412;
}
.ss-status-locked {
  background: #e0e7ff;
  color: #3730a3;
}
.ss-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: 50vh;
  overflow: auto;
}
.ss-tpl-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.ss-tpl-step {
  margin: 0;
  font-weight: 700;
  color: #0f172a;
}
.ss-tpl-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ss-tpl-search {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.95rem;
  background: #fff;
}
.ss-tpl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ss-tpl-filter {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.ss-tpl-filter.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 700;
}
.ss-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding: 2px;
}
.ss-tpl-grid-compact {
  max-height: 280px;
}
.ss-tpl-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  text-align: right;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.ss-tpl-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.12);
}
.ss-tpl-card.selected {
  border-color: #3b82f6;
  background: #f8fbff;
  box-shadow: 0 0 0 1px #3b82f6 inset;
}
.ss-tpl-check {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 0.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.ss-tpl-card.selected .ss-tpl-check { display: inline-flex; }
.ss-tpl-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tpl-color, #2563eb);
  background: color-mix(in srgb, var(--tpl-color, #2563eb) 14%, white);
  flex: 0 0 auto;
}
.ss-tpl-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ss-tpl-ar {
  font-size: 0.98rem;
  color: #0f172a;
  margin: 0;
}
.ss-tpl-en {
  font-size: 0.82rem;
  color: #64748b;
  direction: ltr;
  text-align: right;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.ss-tpl-desc {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
}
.ss-tpl-footer-note {
  margin-inline-end: auto;
  color: #334155;
  font-size: 0.9rem;
}
.modal-footer:has(.ss-tpl-footer-note) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ss-side-hint {
  padding: 12px;
  color: #64748b;
  font-size: 0.92rem;
  text-align: right;
}
.ss-unit-block {
  margin-bottom: 14px;
}
.ss-unit-block h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  text-align: right;
}
.ss-lesson-btn.active {
  border-color: #0284c7;
  background: #f0f9ff;
}
#stepper:has(.ss-step) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  grid-template-columns: none;
}
.ss-step {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e2e8f0;
  font-size: 0.85rem;
}
.ss-step.active {
  background: #0ea5e9;
  color: #fff;
}
.ss-screen-card.dragging {
  opacity: 0.5;
}

/* -------------------------------------------------------------------------- */
/* StorySpark Lesson Builder — three-area workspace (UX Phase 1)              */
/* -------------------------------------------------------------------------- */
body.ss-builder-mode .book-sidebar {
  display: none;
}
body.ss-builder-mode .app-layout {
  grid-template-columns: minmax(0, 1fr);
}
body.ss-builder-mode .main-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.ss-builder-mode .workspace-card {
  flex: 1;
  min-height: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
}
body.ss-builder-mode #stepper {
  display: none;
}

.ss-builder-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  min-height: 0;
  background: #f1f5f9;
  color: #0f172a;
}

.ss-lesson-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.ss-breadcrumbs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #64748b;
}
.ss-bc-link {
  border: none;
  background: none;
  color: #0369a1;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.ss-bc-link:hover { text-decoration: underline; }
.ss-bc-sep { color: #94a3b8; }
.ss-bc-current { color: #0f172a; font-weight: 600; }
.ss-lesson-summary h2 {
  margin: 0;
  font-size: 1.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ss-lesson-summary p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.88rem;
}
.ss-lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ss-builder-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 22%) minmax(0, 1fr) minmax(200px, 25%);
  gap: 0;
}

.ss-nav-panel,
.ss-main-panel,
.ss-context-panel,
.ss-chat-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.ss-nav-panel {
  border-inline-end: 1px solid #e2e8f0;
}
.ss-context-panel,
.ss-chat-panel {
  border-inline-start: 1px solid #e2e8f0;
}
.ss-nav-scroll,
.ss-ws-body,
.ss-ctx-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.ss-chat-panel {
  background: linear-gradient(180deg, #f8fafc 0%, #fff 28%);
}
.ss-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
}
.ss-chat-header h3 {
  margin: 0 0 2px;
  font-size: 1rem;
}
.ss-chat-header p {
  margin: 0;
  color: #64748b;
  font-size: 0.8rem;
}
.ss-chat-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.ss-chat-version,
.ss-preview-version,
.ss-version-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 700;
}
.ss-version-chip {
  margin-inline-start: 8px;
}
.ss-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ss-chat-empty {
  margin: auto;
  text-align: center;
  color: #64748b;
  padding: 18px 12px;
  max-width: 280px;
}
.ss-chat-empty strong {
  display: block;
  color: #0f172a;
  margin-bottom: 6px;
}
.ss-chat-bubble {
  display: flex;
  width: 100%;
}
.ss-chat-user { justify-content: flex-start; }
.ss-chat-assistant { justify-content: flex-end; }
.ss-chat-bubble-inner {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ss-chat-user .ss-chat-bubble-inner {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ss-chat-bubble-inner:has(.ss-chat-user-ref) {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.ss-chat-user-ref {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  padding: 6px 8px;
}
.ss-chat-user-ref-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #dbeafe;
  margin-bottom: 3px;
}
.ss-chat-user-ref p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}
.ss-chat-assistant .ss-chat-bubble-inner {
  background: #f1f5f9;
  color: #0f172a;
  border-bottom-left-radius: 4px;
}
.ss-chat-assistant.is-thinking .ss-chat-bubble-inner,
.ss-chat-assistant.is-applying .ss-chat-bubble-inner {
  background: #eef2ff;
  color: #3730a3;
}
.ss-chat-assistant.is-done .ss-chat-bubble-inner {
  background: #ecfdf5;
  color: #065f46;
}
.ss-chat-assistant.is-error .ss-chat-bubble-inner {
  background: #fef2f2;
  color: #991b1b;
}
.ss-chat-system {
  justify-content: center;
}
.ss-chat-system .ss-chat-bubble-inner {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #64748b;
  font-size: 0.78rem;
  max-width: 100%;
}
.ss-chat-ver-tag {
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}
.ss-chat-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: ss-chat-pulse 1s ease-in-out infinite;
}
@keyframes ss-chat-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
.ss-chat-composer {
  border-top: 1px solid #e2e8f0;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #fff;
}
.ss-chat-ref {
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #f8fafc;
  padding: 8px 10px;
}
.ss-chat-ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.ss-chat-ref-head strong {
  font-size: 0.78rem;
  color: #334155;
}
.ss-chat-ref-text {
  margin: 0;
  color: #475569;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}
.ss-chat-ref-remove {
  width: 24px;
  height: 24px;
  font-size: 1rem;
  line-height: 1;
  color: #64748b;
}
.ss-chat-composer textarea {
  width: 100%;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 72px;
  font: inherit;
}
.ss-chat-composer-actions {
  display: flex;
  justify-content: flex-start;
}
.ss-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}
.ss-add-sticky {
  margin: 10px;
  width: calc(100% - 20px);
  flex: 0 0 auto;
}

.ss-nav-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  background: #fff;
}
.ss-nav-row:hover { background: #f8fafc; }
.ss-nav-row.selected {
  background: #f0f9ff;
  border-color: #0284c7;
}
.ss-nav-row.selected .ss-nav-title { font-weight: 700; }
.ss-nav-row.dragging { opacity: 0.45; }
.ss-nav-handle {
  color: #94a3b8;
  cursor: grab;
  font-size: 0.75rem;
  line-height: 1.2;
  user-select: none;
}
.ss-nav-num {
  font-weight: 700;
  font-size: 0.82rem;
  color: #475569;
  min-width: 1.5rem;
}
.ss-nav-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ss-nav-title {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-nav-meta {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-nav-more-wrap { position: relative; }
.ss-icon-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  line-height: 1;
}
.ss-more-menu {
  position: absolute;
  inset-inline-end: 0;
  top: 100%;
  z-index: 20;
  min-width: 180px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 6px;
  display: grid;
}
.ss-more-menu[hidden] { display: none !important; }
.ss-more-menu button {
  border: none;
  background: transparent;
  text-align: right;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
}
.ss-more-menu button:hover { background: #f1f5f9; }
.ss-more-menu .ss-danger { color: #b91c1c; }
.ss-more-menu .ss-danger:hover { background: #fef2f2; }

.ss-main-panel { background: #f8fafc; }
.ss-ws-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px 8px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.ss-ws-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.ss-ws-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.ss-ws-tab,
.ss-ctx-tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: #64748b;
  border-bottom: 2px solid transparent;
}
.ss-ws-tab.active,
.ss-ctx-tab.active {
  color: #0369a1;
  border-bottom-color: #0284c7;
  font-weight: 600;
}
.ss-ws-body { padding: 14px 16px; }
.ss-muted { color: #64748b; font-size: 0.88rem; }
.ss-empty-pane {
  text-align: center;
  padding: 28px 16px;
  color: #64748b;
}
.ss-content-summary,
.ss-sources-view { display: grid; gap: 10px; }
.ss-field-row,
.ss-source-card,
.ss-ctx-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}
.ss-field-key,
.ss-ctx-block label {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 4px;
}
.ss-field-val,
.ss-ctx-block p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Content tab: generation-context cards + revision source snapshot */
.ss-ctx-collapse {
  margin-top: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.ss-ctx-collapse > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding: 12px 14px;
  list-style: none;
}
.ss-ctx-collapse > summary::-webkit-details-marker { display: none; }
.ss-ctx-collapse > summary h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
}
.ss-ctx-collapse-arrow {
  color: #64748b;
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}
.ss-ctx-collapse[open] .ss-ctx-collapse-arrow { transform: rotate(180deg); }
.ss-ctx-collapse-body { padding: 0 14px 14px; }
.ss-ctx-collapse-body .ss-src-section:first-child { margin-top: 0; }
.ss-ctx-subcollapse {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}
.ss-ctx-subcollapse > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  padding: 10px 12px;
  list-style: none;
}
.ss-ctx-subcollapse > summary::-webkit-details-marker { display: none; }
.ss-ctx-subcollapse > summary h4 { margin: 0; }
.ss-ctx-subcollapse[open] > summary .ss-ctx-collapse-arrow { transform: rotate(180deg); }
.ss-ctx-subcollapse > .ss-src-list { padding: 0 12px 12px; }
.ss-src-section { margin-top: 18px; }
.ss-src-section h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #0f172a;
}
.ss-muted-inline { font-size: 0.75rem; color: #64748b; font-weight: 400; }
.ss-src-list { display: grid; gap: 8px; }
.ss-ctx-cards { display: grid; gap: 8px; }
.ss-ctx-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ss-ctx-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  border-inline-start: 3px solid #94a3b8;
}
.ss-ctx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.ss-ctx-card-head label {
  margin-bottom: 0;
}
.ss-copy-prompt-btn {
  width: 28px;
  height: 28px;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.ss-ctx-prompt-edit {
  margin-top: 10px;
  border: 1px solid #bbf7d0;
  border-right: 3px solid #22c55e;
  border-radius: 10px;
  background: #f0fdf4;
  padding: 8px 10px;
}
.ss-ctx-edit-tag {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 4px;
}
.ss-ctx-prompt-edit p {
  margin: 0;
  color: #166534;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ss-copy-prompt-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.ss-ctx-card label {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 4px;
}
.ss-ctx-card p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ss-ctx-pre {
  margin: 0;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  max-height: 280px;
  overflow: auto;
}
.ss-ctx-details summary {
  cursor: pointer;
  color: #334155;
  font-size: 0.85rem;
  list-style: none;
}
.ss-ctx-details summary::-webkit-details-marker { display: none; }
.ss-ctx-details[open] summary { margin-bottom: 8px; color: #64748b; }
.ss-source-card p { margin: 0; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.ss-source-card { display: flex; gap: 8px; align-items: flex-start; }
.ss-src-structured .ss-src-body { display: grid; gap: 4px; min-width: 0; flex: 1; }
.ss-src-structured .ss-src-body strong { color: #0f172a; font-size: 0.85rem; }
.ss-src-kind {
  font-size: 0.72rem;
  color: #64748b;
}
.ss-src-num {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ss-src-details { display: block; }
.ss-src-details summary {
  cursor: pointer;
  line-height: 1.6;
  color: #334155;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.ss-src-details summary::-webkit-details-marker { display: none; }
.ss-src-details .ss-src-more { color: #1d4ed8; font-size: 0.75rem; margin-inline-start: 6px; }
.ss-src-details[open] .ss-src-more { display: none; }
.ss-src-details[open] summary { color: #64748b; font-size: 0.78rem; margin-bottom: 6px; }
.ss-src-details p { margin: 6px 0 0; }
.ss-rev-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.ss-rev-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.8rem;
}
.ss-rev-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.ss-rev-item.is-ok .ss-rev-icon { background: #dcfce7; color: #166534; }
.ss-rev-item.is-fail .ss-rev-icon { background: #fee2e2; color: #991b1b; }
.ss-rev-label { flex: 1; color: #0f172a; }
.ss-rev-time { color: #94a3b8; font-size: 0.72rem; }

.ss-preview-pane { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 320px; }
.ss-preview-frame {
  flex: 1;
  min-height: 360px;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

.ss-ctx-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 6px;
}
.ss-progress-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.ss-progress-stats div {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.ss-progress-stats strong { display: block; font-size: 1.2rem; }
.ss-progress-stats span { font-size: 0.75rem; color: #64748b; }
.ss-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ss-progress-bar i {
  display: block;
  height: 100%;
  background: #0284c7;
}
.ss-validation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}
.ss-validation-list .ok { color: #166534; }
.ss-validation-list .warn { color: #9a3412; }

.ss-status-draft { background: #f1f5f9; color: #475569; }
.ss-status-edited { background: #ffedd5; color: #9a3412; }
.ss-status-generated { background: #cffafe; color: #0e7490; }

/* Schema-driven content editor (UX Phase 2) */
.ss-schema-editor { display: grid; gap: 12px; }
.ss-ed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  padding: 6px 0 8px;
}
.ss-save-status {
  font-size: 0.82rem;
  color: #64748b;
}
.ss-save-status[data-state="saving"] { color: #0369a1; }
.ss-save-status[data-state="saved"] { color: #166534; }
.ss-save-status[data-state="error"] { color: #b91c1c; }
.ss-ed-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
}
.ss-ed-form { display: grid; gap: 12px; }
.ss-ed-field {
  display: grid;
  gap: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}
.ss-ed-label {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 600;
  margin: 0;
}
.ss-req { color: #b91c1c; }
.ss-ed-field input[type="text"],
.ss-ed-field input[type="number"],
.ss-ed-field textarea,
.ss-ed-field select,
.ss-ed-list-row input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}
.ss-ed-field textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
.ss-ed-json { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.ss-ed-check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.ss-ed-repeater {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 10px;
}
.ss-ed-rep-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ss-ed-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}
.ss-ed-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ss-ed-list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 6px;
}
.ss-danger-text { color: #b91c1c !important; }

@media (max-width: 1100px) {
  .ss-builder-grid {
    grid-template-columns: minmax(180px, 28%) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(260px, 34vh);
  }
  .ss-chat-panel {
    grid-column: 1 / -1;
    border-inline-start: none;
    border-top: 1px solid #e2e8f0;
  }
  .ss-context-panel {
    display: none;
  }
}
@media (max-width: 760px) {
  .ss-builder-grid {
    grid-template-columns: 1fr;
  }
  .ss-nav-panel {
    max-height: 40vh;
    border-inline-end: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .ss-lesson-bar {
    grid-template-columns: 1fr;
  }
}

.modal-body label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}
.ss-edit-form {
  display: grid;
  gap: 4px;
  text-align: right;
}
.ss-edit-section-title {
  margin: 14px 0 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
}
.ss-edit-section-title:first-child {
  margin-top: 0;
}
.ss-edit-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.ss-edit-form .ss-template-grid {
  max-height: 28vh;
  margin-bottom: 4px;
}
.ss-edit-form textarea {
  min-height: 110px;
  resize: vertical;
}

/* -------------------------------------------------------------------------- */
/* StorySpark dashboard shell (Projects / Units)                               */
/* -------------------------------------------------------------------------- */
.ss-dash-sidebar {
  background: #f8fafc;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ss-assist-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(145deg, #7c6ff7, #6366f1 55%, #4f46e5);
  color: #fff;
  border-radius: var(--ss-radius);
  padding: 14px;
  box-shadow: var(--ss-shadow);
}
.ss-assist-card strong { display: block; margin-bottom: 4px; }
.ss-assist-card p { margin: 0; font-size: 0.86rem; opacity: 0.95; line-height: 1.5; }
.ss-assist-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.18);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex: 0 0 auto;
}
.ss-side-block {
  background: #fff;
  border: 1px solid var(--ss-line);
  border-radius: var(--ss-radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.ss-side-block > strong {
  display: block;
  margin-bottom: 10px;
  font-size: 0.92rem;
}
.ss-stepper-v {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.ss-stepper-v li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ss-muted);
}
.ss-stepper-v li span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: #fff;
}
.ss-stepper-v li.active { color: var(--ss-ink); }
.ss-stepper-v li.active span {
  border-color: var(--ss-violet);
  background: var(--ss-violet);
  color: #fff;
}
.ss-stepper-v li.done span {
  border-color: #22c55e;
  background: #dcfce7;
  color: #166534;
}
.ss-stepper-v b { display: block; font-size: 0.88rem; }
.ss-stepper-v small { color: var(--ss-muted); font-size: 0.78rem; }
.ss-side-link {
  display: block;
  width: 100%;
  text-align: right;
  background: #f8fafc;
  border: 1px solid var(--ss-line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  color: var(--ss-ink);
  cursor: pointer;
}
.ss-side-link:hover { border-color: #a5b4fc; background: #eef2ff; }
.ss-side-tip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: 14px;
  padding: 12px;
  font-size: 0.84rem;
  line-height: 1.55;
}
.ss-side-cta { width: 100%; margin-top: 4px; }
.ss-prog-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin: 8px 0 6px;
}
.ss-legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ss-muted);
}
.ss-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-inline-end: 6px;
}
.ss-legend .dot.ok { background: #22c55e; }
.ss-legend .dot.mid { background: #8b5cf6; }
.ss-legend .dot.todo { background: #cbd5e1; }

.main-panel .stepper:empty { display: none; }
.workspace-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.ss-dash {
  display: grid;
  gap: 16px;
  padding: 8px 4px 24px;
  text-align: right;
  direction: rtl;
}
.ss-dash-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ss-view-tabs {
  display: inline-flex;
  gap: 6px;
  background: #eef2ff;
  padding: 4px;
  border-radius: 999px;
}
.ss-view-tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  color: #64748b;
  font-weight: 600;
  cursor: pointer;
}
.ss-view-tab.active {
  background: var(--ss-violet);
  color: #fff;
  box-shadow: 0 6px 16px rgba(109, 94, 252, 0.28);
}
.ss-view-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.ss-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ss-muted);
  font-size: 0.86rem;
}
.ss-hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 16px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--ss-line);
  border-radius: 24px;
  padding: 22px 24px;
  box-shadow: var(--ss-shadow);
  overflow: hidden;
  position: relative;
}
.ss-hero-compact { grid-template-columns: 1fr; }
.ss-hero-copy h2 {
  margin: 8px 0;
  font-size: 1.7rem;
  color: var(--ss-ink);
}
.ss-hero-copy p { margin: 0; color: var(--ss-muted); max-width: 46ch; }
.ss-pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ss-violet-soft);
  color: #4c1d95;
  font-size: 0.78rem;
  font-weight: 700;
}
.ss-hero-art {
  min-height: 120px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 30%, #ddd6fe, transparent 55%),
    radial-gradient(circle at 70% 60%, #bfdbfe, transparent 50%),
    linear-gradient(135deg, #f5f3ff, #eff6ff);
  position: relative;
}
.ss-hero-art::before,
.ss-hero-art::after {
  content: "";
  position: absolute;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.ss-hero-art::before {
  width: 64px;
  height: 78px;
  inset-inline-end: 28%;
  top: 18%;
  transform: rotate(-8deg);
}
.ss-hero-art::after {
  width: 72px;
  height: 56px;
  inset-inline-end: 12%;
  bottom: 18%;
  border-radius: 14px;
  background: linear-gradient(135deg, #93c5fd, #6366f1);
}
.ss-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}
.ss-toolbar input[type="search"] {
  flex: 1;
  border: 1px solid var(--ss-line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.ss-toolbar-meta {
  color: var(--ss-muted);
  font-size: 0.84rem;
  white-space: nowrap;
}
.ss-project-list {
  display: grid;
  gap: 12px;
}
.ss-project-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--ss-line);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ss-project-card:hover,
.ss-project-card.active {
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.12);
}
.ss-project-card.active { border-width: 2px; border-color: #3b82f6; }
.ss-project-thumb {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  flex: 0 0 auto;
}
.ss-project-body h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.ss-project-body p {
  margin: 0;
  color: var(--ss-muted);
  font-size: 0.88rem;
}
.ss-subject-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.ss-prompt-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
}
.ss-prompt-badge.is-set {
  background: #ecfdf5;
  color: #047857;
}
.ss-prompt-badge.is-empty {
  background: #f1f5f9;
  color: #64748b;
}
.ss-project-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ss-project-head h3 { margin: 0; }
.ss-badge-current {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.ss-project-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  color: var(--ss-muted);
  font-size: 0.78rem;
}
.ss-units-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}
.ss-units-head h2 { margin: 0 0 4px; font-size: 1.45rem; }
.ss-mini-stat {
  background: #fff;
  border: 1px solid var(--ss-line);
  border-radius: 16px;
  padding: 10px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.ss-mini-stat strong { display: block; color: #16a34a; font-size: 1.1rem; }
.ss-mini-stat span { font-size: 0.75rem; color: var(--ss-muted); }
.ss-unit-stack { display: grid; gap: 12px; }
.ss-unit-acc {
  background: #fff;
  border: 1px solid var(--ss-line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ss-unit-acc-head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border: none;
  text-align: right;
  cursor: pointer;
}
.ss-unit-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--ss-violet-soft);
  display: grid;
  place-items: center;
}
.ss-unit-acc-copy h3 { margin: 0 0 2px; font-size: 1rem; }
.ss-unit-acc-copy p { margin: 0; color: var(--ss-muted); font-size: 0.82rem; }
.ss-chevron { color: var(--ss-muted); font-size: 0.9rem; }
.ss-unit-acc-body {
  border-top: 1px solid var(--ss-line);
  padding: 8px 12px 12px;
  background: #fbfcff;
}
.ss-lesson-row-v2 {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid transparent;
  margin-bottom: 8px;
  cursor: pointer;
}
.ss-lesson-row-v2:hover { border-color: #c7d2fe; background: #f8fafc; }
.ss-lesson-row-v2 strong { font-size: 0.92rem; }
.ss-unit-acc-foot { display: flex; justify-content: flex-start; padding-top: 4px; }
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  border: none;
}
.btn-primary:hover { filter: brightness(1.05); }

@media (max-width: 960px) {
  .ss-hero { grid-template-columns: 1fr; }
  .ss-hero-art { min-height: 90px; }
  .ss-project-card {
    grid-template-columns: auto 1fr;
  }
  .ss-subject-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .ss-subject-actions .btn { flex: 1; }
  .ss-project-card .btn { grid-column: auto; }
  .ss-lesson-row-v2 {
    grid-template-columns: 1fr auto;
  }
}
