:root {
  /* skillsforwork Brand Colors */
  --primary: #FFD32B;            /* Gelb – primärer Akzent */
  --primary-hover: #EFB604;      /* Dunkleres Gelb – Hover/Ränder */
  --primary-light: #FFFEF9;      /* Sehr helles Gelb – Hintergrund-Tint */
  --primary-dark: #162455;       /* Navy – Text auf gelben Flächen */

  --accent-blue: #165DFB;        /* Blau – tertiärer/Aktions-Button */
  --accent-blue-hover: #1048D0;
  --accent-blue-dark: #162455;   /* Navy – Rahmen für Blau-Button */

  --secondary: #90A2B9;          /* Mittel-Grau – Border sekundärer Buttons */
  --secondary-hover: #45556C;

  --success: #10b981;
  --danger: #ef4444;
  --warning: #EFB604;

  --bg-app: #EFF6FF;             /* Hellblau – Seitenhintergrund */
  --bg-sidebar: #ffffff;
  --bg-editor: #E8F0FA;          /* Etwas dunkler für Editor-Bereich */
  --bg-box: #F8FAFB;             /* Helle Boxen */

  --text-main: #020617;          /* Fast Schwarz */
  --text-muted: #45556C;         /* Blau-Grau für sekundären Text */
  --text-white: #ffffff;
  --text-on-primary: #162455;    /* Navy – für Text auf gelben Buttons */

  --border-light: #CAD5E2;       /* Helles Blau-Grau */
  --border-medium: #90A2B9;      /* Mittleres Grau für Box-Ränder */
  --border-focus: #FFD32B;       /* Gelb – Fokus-Ring */

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  --shadow-box: 0px 12px 32px rgba(12, 12, 13, 0.10); /* Brand Guide Box-Schatten */

  --radius-sm: 0.375rem;         /* 6px */
  --radius-md: 0.875rem;         /* 14px – Buttons (Brand Guide) */
  --radius-lg: 2rem;             /* 32px – Boxes/Cards (Brand Guide) */
  --radius-full: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  background: #ffffff;
  color: var(--text-main);
  padding: 0 1.25rem;
  height: 64px;
  min-height: 64px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  z-index: 500;
  position: relative;
}

.app-logo,
.btn-logo {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.app-logo-img {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
}


.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-box);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 3px;
  flex-shrink: 0;
}

.lang-btn {
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
  font-family: inherit;
}

.lang-btn.active {
  background: white;
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lang-btn:hover:not(.active) {
  color: var(--text-main);
}

/* Start Screen */
.start-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-app);
  position: relative;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.start-screen-content {
  max-width: 1100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
  position: relative;
}

.start-screen-main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start-screen-eyebrow {
  display: inline-flex;
  align-self: center;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  background: var(--primary);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 0.5px solid var(--primary-hover);
  box-shadow: 0px 4px 12px rgba(239, 182, 4, 0.2);
}

.start-screen-eyebrow i,
.start-screen-eyebrow svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.start-screen-content h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
  text-wrap: balance;
  max-width: 500px;
  line-height: 1.15;
}

.start-screen-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.start-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  text-align: left;
}

[data-feature-group] {
  display: none !important;
}

.start-feature-group {
  display: contents;
}

.start-option {
  background: #ffffff;
  border: 0.5px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  text-align: center;
  width: 100%;
  max-width: 340px;
  flex: 1 1 220px;
}

.start-option:hover:not(:disabled) {
  border-color: var(--primary-hover);
  box-shadow: 0px 12px 32px rgba(239, 182, 4, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.start-option:active:not(:disabled) {
  transform: translateY(0);
}

.start-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.start-option-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(239, 182, 4, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.start-option-icon svg,
.start-option-icon i {
  width: 18px;
  height: 18px;
}

.start-option:disabled .start-option-icon {
  background: var(--bg-box);
  color: var(--border-medium);
  box-shadow: none;
}

.start-option h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  text-wrap: balance;
}

.start-option:disabled h3 {
  color: var(--border-medium);
}

.start-option-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  text-wrap: balance;
}


.start-option-teaser {
  opacity: 0.7;
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fb 100%);
  border-style: dashed;
}

.start-option-teaser .start-option-icon {
  background: #eef2f7;
  color: var(--secondary);
  box-shadow: none;
}

.start-option-teaser h3,
.start-option-teaser .start-option-desc {
  color: var(--text-muted);
}

.start-secondary-actions {
  margin-top: clamp(2rem, 10vh, 5rem);
  display: flex;
  justify-content: center;
}

.start-secondary-items {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.start-secondary-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  transition: color 0.15s ease, background 0.15s ease;
  text-decoration: none;
}

.start-secondary-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.8);
}

.start-secondary-item svg,
.start-secondary-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

@media (min-width: 901px) and (min-height: 860px) {
  .start-screen-content {
    min-height: calc(100vh - 64px - 4rem);
    padding-bottom: 7.5rem;
  }

  .start-screen-main {
    flex: 1 1 auto;
    min-height: 0;
    justify-content: center;
  }

  .start-secondary-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin-top: 0;
  }
}


.btn {
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-dark);
  border-color: var(--primary-hover);
  box-shadow: 0px 4px 12px rgba(239, 182, 4, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0px 8px 20px rgba(239, 182, 4, 0.35);
}

.btn-secondary {
  background: white;
  border-color: var(--border-medium);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-box);
  border-color: var(--secondary-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: #dc2626;
  box-shadow: 0px 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: #dc2626;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0px 8px 20px rgba(239, 68, 68, 0.3);
}


.app-main {
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* Editor Styles */
.editor-view {
  display: flex;
  width: 100%;
  height: 100%;
}

.editor-sidebar {
  width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  overflow-x: visible;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  overflow: visible;
}

.sidebar-section h3 {
  font-size: 0.6875rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 {
  margin-bottom: 0;
}

/* Klappbar: Kurs-Einstellungen, Inhaltsverzeichnis, Komponenten, Endscreen */
.sidebar-section-collapsible .section-content-collapsible {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 2000px;
  overflow: hidden;
  margin-top: 0.5rem;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease, padding 0.25s ease;
}

.section-content-collapsible .form-group {
  margin-bottom: 0;
}

.section-content-collapsible textarea.form-input {
  resize: none;
}

#endscreen-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}


#toc-content.section-content-collapsible {
  max-height: 420px;
  overflow-y: auto;
}

.sidebar-section-collapsible.collapsed .section-content-collapsible {
  max-height: 0 !important;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  pointer-events: none;
}

.sidebar-section-collapsible.collapsed .section-header {
  margin-bottom: 0;
}

.section-header-clickable {
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

.section-header-clickable:hover {
  color: var(--primary-dark);
}

.section-header-clickable .collapse-icon {
  display: flex;
  align-items: center;
  transition: transform 0.25s ease;
}

.sidebar-section-collapsible.collapsed .section-header-clickable .collapse-icon {
  transform: rotate(-90deg);
}

/* Vollbreiter Button unter der Screen-Liste */
.btn-add-screen-full {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.btn-add-screen-full:hover {
  background: #FFFEF9;
  border-color: var(--primary-hover);
  color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(239, 182, 4, 0.15);
}

.form-group {
  margin-bottom: 1.25rem;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text-main);
}

.toggle-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.toggle-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all 0.2s;
  background: var(--bg-app);
  min-height: 2.75rem;
  box-sizing: border-box;
}

select.form-input {
  height: 2.75rem;
  padding-top: 0;
  padding-bottom: 0;
  appearance: auto;
  cursor: pointer;
  line-height: 2.75rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #ffffff;
}

/* ── Rich Text Editor ──────────────────────────────────────────────────────── */
.rich-text-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--bg-box);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  flex-wrap: wrap;
}

.rte-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  padding: 0;
  flex-shrink: 0;
}

.rte-btn:hover {
  background: var(--border-light);
  color: var(--text-main);
}

.rte-btn.active,
.rte-btn:active,
.rte-btn-active {
  background: var(--primary);
  color: var(--primary-dark);
}

.rte-btn-heading {
  width: auto;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-family: inherit;
}

.heading-level-toolbar {
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.heading-text-editor {
  min-height: auto;
  white-space: nowrap;
  overflow: hidden;
}

.rte-btn svg,
.rte-btn i {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.rte-divider {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  margin: 0 3px;
  flex-shrink: 0;
}

.rich-text-editor {
  width: 100%;
  min-height: 140px;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-app);
  line-height: 1.6;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rich-text-editor.rte-compact {
  min-height: 80px;
}

.rich-text-editor:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #ffffff;
}

.rich-text-editor ul,
.rich-text-editor ol {
  padding-left: 1.5rem;
  margin: 0.25rem 0;
}

.rich-text-editor li {
  margin: 0.1rem 0;
}

.rich-text-editor p {
  margin: 0.2rem 0;
}

/* Rich text in preview/player */
.text-rich-content {
  line-height: 1.6;
  color: var(--text-main);
}

.text-rich-content h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.25rem 0 0.375rem;
}

.text-rich-content h2:first-child {
  margin-top: 0;
}

.text-rich-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0.75rem 0 0.25rem;
}

.text-rich-content ul,
.text-rich-content ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.text-rich-content li {
  margin: 0.2rem 0;
}

.text-rich-content p {
  margin: 0.25rem 0;
}

.text-rich-content code,
.flipcard-content code {
  background: var(--bg-app);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--text-main);
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  font-size: 0.875rem;
  color: var(--text-main);
}

.toc-item:hover {
  background: var(--bg-box);
}

.toc-item.toc-active {
  background: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.toc-number {
  background: var(--border-light);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.toc-item.toc-active .toc-number {
  background: var(--primary-dark);
  color: white;
}

.toc-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ── Chapter / Lesson structure in sidebar ── */
.chapter-group {
  margin-bottom: 0.75rem;
}

.chapter-group:last-child {
  margin-bottom: 0;
}

.chapter-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.25rem;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.chapter-header:hover {
  background: var(--bg-box);
}

.chapter-collapse-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.chapter-collapse-icon i, .chapter-collapse-icon svg {
  width: 14px;
  height: 14px;
}

.chapter-group.collapsed .chapter-collapse-icon {
  transform: rotate(-90deg);
}

.chapter-group.collapsed .chapter-lessons {
  display: none;
}

.chapter-title-input {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  font-family: inherit;
  cursor: text;
}

.chapter-title-input:hover {
  background: rgba(0,0,0,0.02);
}

.chapter-title-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: white;
}

.chapter-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.chapter-header:hover .chapter-actions {
  opacity: 1;
}

.chapter-lessons {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.375rem 0 0 0.25rem;
}

/* TOC chapter label (preview + player) */
.toc-chapter-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.75rem 0.25rem;
  user-select: none;
}

.toc-chapter-label:first-child {
  padding-top: 0.25rem;
}

.screen-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  overflow-y: auto;
  overflow-x: visible;
  max-height: 400px;
  padding: 0;
}

.screen-list::-webkit-scrollbar {
  width: 4px;
}

.screen-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}

.screen-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.625rem;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: move;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: visible;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.screen-item:hover {
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.screen-item.selected {
  background: var(--primary);
  border-color: var(--primary-hover);
}

.screen-item.dragging {
  opacity: 0.5;
  border-style: dashed;
}

.screen-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  overflow: hidden;
}

.screen-number {
  background: var(--bg-app);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.screen-item.selected .screen-number {
  background: var(--primary);
  color: var(--primary-dark);
}

.screen-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--primary);
  color: var(--primary-dark);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-icon-small {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}

.btn-icon-small:hover {
  color: var(--danger);
}

.editor-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  background: var(--bg-editor);
  padding: 1.5rem 1.5rem;
}

.screen-editor {
  max-width: 860px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.07);
  overflow: visible;
}

.screen-header {
  padding: 1.25rem 1.75rem 0.625rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: #ffffff;
  border-radius: 16px 16px 0 0;
}

.screen-title-input {
  width: 100%;
  font-size: 1.75rem;
  font-weight: 800;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.2rem 0;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
  border-radius: 6px;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.screen-title-input:hover {
  background: rgba(0, 0, 0, 0.02);
}

.screen-title-input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.components-container {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1rem;
  row-gap: 1rem;
  align-items: flex-start;
  align-content: flex-start;
  padding: 0.75rem 1.75rem 2rem;
  min-height: 200px;
  overflow: visible;
  flex: 1;
}

/* Heading → Text/rich-content: keep tight spacing */
.components-container > .ctype-heading + .ctype-text {
  margin-top: -0.5rem;
}

/* Fehler-Anzeige */
.error {
  padding: 1.5rem;
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #991b1b;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  font-weight: 600;
}

/* Hilfsklassen für Debugging */
.empty-state {
  text-align: center;
  padding: 2.5rem 2rem;
  color: var(--text-muted);
  border: 2px dashed var(--border-light);
  border-radius: 10px;
  margin: 0.5rem 0;
  flex: 0 0 100%;
}

.component-wrapper {
  flex: 0 0 100%;
  position: relative;
  margin-bottom: 0;
  margin-right: 0;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Smart spacing: box elements get breathing room in editor */
.components-container > * + .ctype-accordion,
.components-container > * + .ctype-quiz,
.components-container > * + .ctype-tabs,
.components-container > * + .ctype-textimage,
.components-container > * + .ctype-image,
.components-container > * + .ctype-flipcard {
  margin-top: 0.75rem;
}

.components-container > .ctype-accordion + *,
.components-container > .ctype-quiz + *,
.components-container > .ctype-tabs + *,
.components-container > .ctype-textimage + *,
.components-container > .ctype-image + *,
.components-container > .ctype-flipcard + * {
  margin-top: 0.75rem;
}

/* ── Drop Indicator (Palette → Editor drag & drop) ────────────────── */

.drop-target-active {
  min-height: 120px;
}

.drop-indicator {
  flex: 0 0 100%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--primary-hover);
  margin: 0.25rem 0;
  box-shadow: 0 0 8px rgba(239, 182, 4, 0.4);
  pointer-events: none;
  animation: drop-indicator-pulse 1s ease-in-out infinite;
}

@keyframes drop-indicator-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.palette-item.dragging {
  opacity: 0.5;
}

/* The visible card – Notion-style: no visible border by default */
.component-card {
  position: relative;
  background: transparent;
  border-radius: 8px;
  overflow: visible;
  cursor: pointer;
  transition: background 0.1s;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.component-wrapper:hover .component-card {
  background: rgba(0, 0, 0, 0.026);
}

.component-wrapper.dragging {
  opacity: 0.4;
}

.screen-item.drag-over-top {
  border-top: 3px solid var(--primary-hover);
}

.screen-item.drag-over-bottom {
  border-bottom: 3px solid var(--primary-hover);
}

/* Toolbar – floating badge, absolutely positioned, no layout impact */
.component-toolbar {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px 3px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  white-space: nowrap;
}

.component-wrapper:hover .component-toolbar {
  opacity: 1;
  pointer-events: auto;
}

.component-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: grab;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  flex-shrink: 0;
}

.component-handle:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

.component-handle:active {
  cursor: grabbing;
}

.component-handle svg,
.component-handle i {
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.component-type-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
  padding: 0 2px;
}

.component-toolbar-actions {
  display: flex;
  gap: 1px;
}

.component-body {
  padding: 0.25rem 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.component-body a.download-btn {
  pointer-events: none;
}

/* ── Editor component rendering ─────────────────────────────────────────
   Uses the SAME visual language as .preview-content. No extra overrides
   except margin: 0 (spacing handled by row-gap on .components-container).
   ──────────────────────────────────────────────────────────────────────── */

/* Headings */
.component-body h1,
.component-body h2,
.component-body h3,
.component-body h4,
.component-body h5,
.component-body h6 {
  margin: 0;
  color: var(--text-main);
  line-height: 1.3;
}

.component-body h1 { font-size: 1.875rem; font-weight: 800; }
.component-body h2 { font-size: 1.5rem;   font-weight: 700; }
.component-body h3 { font-size: 1.25rem;  font-weight: 700; }
.component-body h4 { font-size: 1.075rem; font-weight: 600; }

/* Text */
.component-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.component-body .text-rich-content {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

/* Figure / Image */
.component-body figure {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.component-body figure img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: cover;
}

/* Placeholders – same visual as global but fit the editor card */
.component-body .image-placeholder,
.component-body .video-placeholder {
  padding: 2.5rem 1.5rem;
}

.btn-action {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0;
  width: 22px;
  height: 22px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-action svg,
.btn-action i {
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.btn-action:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main);
}

.btn-action.btn-delete:hover {
  background: #fee2e2;
  color: var(--danger);
}

/* Component Palette */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding-top: 4px;
}

#component-palette-content.section-content-collapsible {
  overflow: visible;
}

.sidebar-section-collapsible.collapsed #component-palette-content.section-content-collapsible {
  overflow: hidden;
}

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.palette-item:hover {
  background: #FFFEF9;
  border-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(239, 182, 4, 0.15);
}

.palette-icon {
  font-size: 1.5rem;
  color: var(--primary-dark);
}

.palette-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
}

/* Shared non-quiz component styles moved to `lib/shared-components.css` */

.quiz-component {
  border: 0.5px solid var(--border-medium);
  border-left: 4px solid var(--primary-hover);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 0;
  background: #ffffff;
  box-shadow: var(--shadow-box);
}

.quiz-component h3 {
  margin-bottom: 1.5rem;
  color: var(--text-main);
  font-size: 1.25rem;
  font-weight: 700;
}

.quiz-single-block {
  padding: 1.5rem 0;
}

.quiz-single-block + .quiz-single-block {
  border-top: 1px solid var(--border-light);
}

.quiz-single-block:first-child {
  padding-top: 0;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-box);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.quiz-option:hover {
  background: var(--primary-light);
  border-color: var(--primary-hover);
}

.quiz-option.show-correct {
  border-color: #10b981;
  background: #d1fae5;
  color: #065f46;
}

.quiz-option input[type="radio"],
.quiz-option input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  accent-color: var(--primary-dark);
}

.btn-check {
  padding: 0.75rem 2rem;
  background: var(--primary);
  color: var(--primary-dark);
  border: 0.5px solid var(--primary-hover);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  width: 100%;
  box-shadow: 0px 4px 12px rgba(239, 182, 4, 0.2);
}

.btn-check:hover {
  background: var(--primary-hover);
  color: var(--primary-dark);
  box-shadow: 0px 8px 20px rgba(239, 182, 4, 0.3);
}

.quiz-feedback {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quiz-feedback.correct {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.quiz-feedback.incorrect {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Preview Styles */
.preview-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.preview-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Preview Sidebar (same push-layout as player) */
.preview-sidebar {
  flex: 0 0 280px;
  width: 280px;
  background: #ffffff;
  border-right: 1px solid var(--border-light);
  overflow: hidden;
  transition: flex-basis 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.preview-sidebar.collapsed {
  flex-basis: 0;
  width: 0;
}

/* Inner scroll wrapper (prevents reflow during animation) */
.preview-sidebar-inner {
  width: 280px;
  min-width: 280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem;
}

/* ── Sidebar Header (shared between preview + player) – match .section-header */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0;
  margin-bottom: 1rem;
  border-bottom: none;
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
}

/* Close button inside sidebar */
.sidebar-toggle {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--primary);
  border-color: var(--primary-hover);
  color: var(--primary-dark);
}

/* Open button (floating, shown when sidebar collapsed) */
.sidebar-toggle-btn {
  position: absolute;
  left: 1rem;
  top: 1rem;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

.preview-sidebar.collapsed ~ .sidebar-toggle-btn {
  display: flex;
}

.sidebar-toggle-btn:hover {
  background: var(--primary);
  color: var(--primary-dark);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.preview-toc {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Outer scroll container – fills remaining space, scrollbar at window edge */
.preview-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Inner centering container – max-width, no own scroll */
.preview-content {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.5rem;
  row-gap: 1.5rem;
  align-items: flex-start;
  align-content: flex-start;
  padding: 2rem 2.5rem 4rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

/* Heading → Text: keep tight */
.preview-content > .component-heading + .component-text {
  margin-top: -0.75rem;
}

.preview-content > * {
  flex: 0 0 100%;
  box-sizing: border-box;
}

/* Flipcard Grid (rendered inside component) */

/* Smart spacing: box elements get breathing room */
.preview-content > * + .component-accordion,
.preview-content > * + .component-quiz,
.preview-content > * + .component-tabs,
.preview-content > * + .component-textimage,
.preview-content > * + .component-image,
.preview-content > * + .component-flipcard {
  margin-top: 1rem;
}

.preview-content > .component-accordion + *,
.preview-content > .component-quiz + *,
.preview-content > .component-tabs + *,
.preview-content > .component-textimage + *,
.preview-content > .component-image + *,
.preview-content > .component-flipcard + * {
  margin-top: 1rem;
}

.preview-content > h1 + .component-heading {
  margin-top: 0.5rem;
}

/* Screen title h1 – free-standing, not inside a .component wrapper */
.preview-content > h1 {
  margin-bottom: 0.5rem;
  margin-top: 0;
  color: var(--text-main);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

/* Reset ALL margins inside component wrappers –
   spacing is handled exclusively by row-gap on .preview-content */
.preview-content .component h1,
.preview-content .component h2,
.preview-content .component h3,
.preview-content .component h4,
.preview-content .component h5,
.preview-content .component h6,
.preview-content .component p,
.preview-content .component figure,
.preview-content .component .accordion,
.preview-content .component .flipcard-container,
.preview-content .component .quiz-component {
  margin: 0;
}

.preview-content .component .quiz-component h3 {
  margin: 0 0 1.25rem;
}

/* Heading component typography */
.preview-content .component-heading h1 { font-size: 1.875rem; font-weight: 800; }
.preview-content .component-heading h2 { font-size: 1.5rem;   font-weight: 700; }
.preview-content .component-heading h3 { font-size: 1.25rem;  font-weight: 700; }
.preview-content .component-heading h4 { font-size: 1.075rem; font-weight: 600; }

/* Text component */
.preview-content .component-text p,
.preview-content .component-text .text-rich-content {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

/* Image component */
.preview-content .component figure {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.preview-content .component figure img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: cover;
}

.preview-content .component figure.image-size-m { max-width: 50%; }
.preview-content .component figure.image-size-s { max-width: 25%; }

.preview-content .component figcaption {
  margin-top: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.endscreen-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  min-height: 40vh;
  flex: 0 0 100%;
}

.preview-navigation {
  padding: 1rem 2rem;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.05);
  z-index: 50;
}

.btn-nav {
  padding: 0.625rem 1.25rem;
  background: var(--primary);
  color: var(--primary-dark);
  border: 0.5px solid var(--primary-hover);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0px 4px 12px rgba(239, 182, 4, 0.2);
}

.btn-nav:hover:not(:disabled) {
  background: var(--primary-hover);
  color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0px 8px 20px rgba(239, 182, 4, 0.3);
}

.btn-nav:disabled {
  background: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.btn-nav.btn-finish {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0px 4px 12px rgba(22, 93, 251, 0.25);
}

.btn-nav.btn-finish:hover:not(:disabled) {
  background: #0e47d4;
  color: #fff;
  border-color: #0e47d4;
  transform: translateY(-1px);
}

.btn-nav i {
  width: 16px;
  height: 16px;
}

.screen-counter {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-box);
  border: 0.5px solid var(--border-light);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border-medium);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-box);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-light);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close {
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-close:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.array-item {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tab-image-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tab-image-row select {
  flex: 0 0 auto;
  width: auto;
  min-width: 120px;
}

.tab-image-row input[type="file"] {
  flex: 1;
  min-width: 0;
}

.tab-image-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.tab-image-preview img {
  flex-shrink: 0;
}

.tab-image-preview input {
  flex: 1;
  min-width: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-add {
  background: var(--primary);
  color: var(--primary-dark);
  border: 1px solid var(--primary-hover);
  border-radius: var(--radius-md);
  width: 100%;
  padding: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-remove {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove:hover {
  background: #fee2e2;
  border-color: var(--danger);
}

/* ── Quiz Editor Styles ── */

.quiz-question-block {
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quiz-question-header strong {
  font-size: 0.875rem;
  color: var(--text-main);
}

.quiz-option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.quiz-option-row .form-input {
  flex: 1;
  min-width: 0;
}

.checkbox-label-compact {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-muted);
}

.btn-remove-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-remove-sm:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-remove-sm svg, .btn-remove-sm i {
  width: 14px;
  height: 14px;
}

.btn-add-sm {
  background: transparent;
  color: var(--accent-blue);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.btn-add-sm:hover {
  border-color: var(--accent-blue);
  background: #eff6ff;
}

.quiz-q-image-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Unified Image Picker ── */
.image-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.image-picker-compact {
  gap: 0.375rem;
}

.image-picker-has-image {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}

.image-picker-meta {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  width: 100%;
}
.image-picker-meta .form-input {
  font-size: 0.8125rem;
}

.image-picker-upload-btn,
label.image-picker-upload-btn,
button.image-picker-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-light);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0;
  cursor: pointer;
  transition: all 0.2s;
  width: fit-content;
}

.image-picker-upload-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
  background: #fffef5;
}

.image-picker-upload-btn svg,
.image-picker-upload-btn i { width: 16px; height: 16px; }

.image-picker-remove-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s;
}
.image-picker-remove-btn:hover { color: var(--danger, #e53e3e); }
.image-picker-remove-btn svg,
.image-picker-remove-btn i { width: 14px; height: 14px; }

.image-picker-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  display: block;
}

.image-picker-compact .image-picker-thumb {
  width: 60px;
  height: 45px;
}
.image-picker-compact .image-picker-upload-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  gap: 0.25rem;
}
.image-picker-compact .image-picker-btns {
  gap: 0.375rem;
}

.image-picker .form-input {
  font-size: 0.8125rem;
}

/* Legacy quiz image styles (kept for compat) */
.quiz-q-image-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-light);
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-q-image-upload-btn:hover {
  border-color: var(--primary);
  color: var(--text);
  background: #fffef5;
}
.quiz-q-image-upload-btn svg,
.quiz-q-image-upload-btn i { width: 16px; height: 16px; }

.quiz-q-image-uploaded {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quiz-q-image-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.quiz-q-image-change-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-light);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-q-image-change-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}
.quiz-q-image-change-btn svg,
.quiz-q-image-change-btn i { width: 14px; height: 14px; }

.quiz-q-image-preview {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.quiz-q-type-points-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.quiz-q-type-points-row select {
  flex: 1;
}

.quiz-points-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.quiz-points-label input {
  width: 60px;
}

.quiz-q-feedback-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.quiz-config-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.quiz-mode-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: var(--bg-box);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  margin-bottom: 0.75rem;
}

.quiz-mode-badge.quiz-mode-final {
  background: #eff6ff;
  color: var(--accent-blue);
  border-color: #bfdbfe;
}

.quiz-question-preview {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.quiz-question-preview strong {
  display: block;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.quiz-question-preview:last-child {
  border-bottom: none;
}

.quiz-q-thumb {
  max-width: 120px;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
  display: block;
}

/* Quiz question image in preview/player */
.quiz-question-image {
  max-width: 400px;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 0.75rem 0 1rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08);
}

/* Final quiz result in preview */
.quiz-final-question {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.quiz-final-question:first-child {
  padding-top: 0;
}

.quiz-final-question:last-of-type {
  border-bottom: none;
}

.quiz-final-q-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.quiz-final-result {
  text-align: center;
  padding: 2rem;
  margin-top: 1.5rem;
  border-radius: var(--radius-md);
}

.quiz-result-passed {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.quiz-result-failed {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.quiz-result-score {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary-dark);
}

.quiz-result-detail {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0.5rem 0 1rem;
}

.quiz-result-badge {
  display: inline-block;
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 700;
}

.quiz-result-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Mobile: Editor – Vorschau oben, Konfiguration unten */
@media (max-width: 768px) {
  .editor-view {
    flex-direction: column;
  }

  .editor-main {
    order: 1;
    flex: 0 0 auto;
    max-height: 42vh;
    min-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    border-bottom: 2px solid var(--border-light);
  }

  .editor-sidebar {
    order: 2;
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
    border-top: 1px solid var(--border-light);
  }

  .screen-editor {
    max-width: 100%;
  }

  .screen-header {
    padding: 1rem 1rem 0.5rem;
  }

  .components-container {
    padding: 0.25rem 1rem 1.5rem;
    min-height: 180px;
  }

  /* Toolbar auf Mobile immer sichtbar */
  .component-toolbar {
    opacity: 1;
  }

  .palette-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .palette-item {
    padding: 0.75rem 0.5rem;
  }

  .palette-label {
    font-size: 0.7rem;
  }

  .app-header {
    padding: 0 1.25rem;
    height: 56px;
    min-height: 56px;
  }

  .app-logo-img {
    height: 22px;
  }

  .header-right {
    gap: 0.5rem;
  }

  .header-actions > .btn {
    display: none !important;
  }

  .burger-btn {
    display: flex !important;
  }

  .lang-btn {
    padding: 4px 8px;
    font-size: 0.65rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

}

/* ── Burger Menu (Mobile) ─────────────────────────────────────────────────── */
.burger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  width: 36px;
  height: 36px;
  padding: 0;
  transition: background 0.15s;
}

.burger-btn:hover {
  background: var(--bg-app);
}

.burger-btn svg,
.burger-btn i {
  width: 18px;
  height: 18px;
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 200px;
  z-index: 9999;
  flex-direction: column;
  gap: 0.25rem;
}

.mobile-menu.open {
  display: flex;
}

.mobile-menu .btn {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

/* ── Ghost Button (Speichern) ─────────────────────────────────────────────── */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  box-shadow: none;
}
.btn-ghost:hover {
  background: white;
  color: var(--text-main);
  border-color: var(--border-medium);
  transform: none;
  box-shadow: var(--shadow-sm);
}



/* ── KI-Modal ─────────────────────────────────────────────────────────────── */
.ai-modal-content {
  max-width: 680px;
  width: 90vw;
}

.ai-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-modal-fields-compact .form-group {
  margin-bottom: 0;
}
.ai-modal-fields-compact .form-group > .form-hint-text:last-child {
  margin-bottom: 0;
}
.ai-modal-fields-compact .form-group > .form-hint-text + .form-hint-text {
  margin-top: -0.25rem;
}

.imagine-modal-fields {
  gap: 0.625rem;
}
.imagine-modal-fields .form-group {
  margin-bottom: 0;
}
/* Vertikaler Rhythmus wie Mockup: klare Blöcke, knappe Innenabstände */
.imagine-modal-form select.form-input + .imagine-bildstil-label {
  margin-top: 0.75rem;
}
.imagine-modal-form > .form-hint-text {
  margin-bottom: 0.375rem;
  line-height: 1.45;
}
.imagine-modal-form > .form-hint-text + label {
  margin-top: 0.5rem;
}
.imagine-modal-form > .form-hint-text + textarea.form-input {
  margin-top: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}
.form-group-sm {
  min-width: 140px;
}

.form-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

p.form-hint {
  margin: 0.375rem 0 0;
  line-height: 1.4;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.tooltip-wrap {
  position: static;
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  cursor: default;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-app);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  user-select: none;
  transition: color 0.15s;
  border: 1px solid var(--border-light);
}

.tooltip-wrap:hover .tooltip-icon {
  color: var(--text-main);
  border-color: var(--border-medium);
}

/* Bubble is positioned relative to .form-group (position: relative),
   so it always spans the full field width and never overflows the sidebar */
.tooltip-bubble {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  width: auto;
  background: var(--text-main);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  white-space: normal;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tooltip-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: var(--arrow-left, 1.25rem);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-main);
}

.tooltip-wrap:hover .tooltip-bubble {
  display: block;
}
.form-required {
  color: var(--danger);
}
.form-hint-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.ai-textarea {
  resize: vertical;
  min-height: 200px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.ai-pdf-dropzone {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  transition: border-color 0.2s;
}

.ai-pdf-dropzone:hover {
  border-color: var(--primary-hover);
}

.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.ai-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-app);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Spinner animation for loading state */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}


/* ── KI Progress Steps ───────────────────────────────────────────────────── */
.ai-progress-view {
  padding: 0.5rem 0;
}

.ai-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ai-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-light);
  transition: all 0.3s ease;
}
.ai-step:last-child { border-bottom: none; }

.ai-step-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-app);
  border: 2px solid var(--border-light);
  color: var(--text-muted);
  transition: all 0.3s ease;
}
.ai-step-icon i { width: 16px; height: 16px; }

.ai-step[data-status="active"] .ai-step-icon {
  background: var(--primary);
  border-color: var(--primary-hover);
  color: var(--primary-dark);
}
.ai-step[data-status="done"] .ai-step-icon {
  background: #d1fae5;
  border-color: #10b981;
  color: #10b981;
}
.ai-step[data-status="error"] .ai-step-icon {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

.ai-step-body {
  flex: 1;
  padding-top: 0.25rem;
}
.ai-step-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}
.ai-step[data-status="pending"] .ai-step-title {
  color: var(--text-muted);
}
.ai-step[data-status="active"] .ai-step-title {
  color: var(--primary-dark);
}
.ai-step[data-status="done"] .ai-step-title {
  color: #065f46;
}
.ai-step-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.ai-progress-hint {
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Start Screen: Responsive ─────────────────────────────────────────────── */
@media (max-height: 820px) {
  .start-screen {
    align-items: flex-start;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .start-screen-content h1 {
    font-size: 1.75rem;
  }
  .start-option {
    max-width: none;
  }
  .start-option-desc {
    font-size: 0.8125rem;
  }
  .start-secondary-items {
    flex-direction: column;
    gap: 0.5rem;
  }
}

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

/* ── In-App Confirm Dialog ───────────────────────────────────────────────── */

.confirm-dialog-content {
  max-width: 420px;
  padding: 0;
}

.confirm-dialog-body {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.75rem 1.75rem 1.25rem;
}

.confirm-dialog-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.confirm-dialog-icon.icon-warning {
  background: #FEF3C7;
  color: #92400E;
}

.confirm-dialog-icon.icon-danger {
  background: #FEE2E2;
  color: var(--danger);
}

.confirm-dialog-icon.icon-info {
  background: var(--bg-box);
  color: var(--text-muted);
}

.confirm-dialog-icon svg,
.confirm-dialog-icon i {
  width: 20px;
  height: 20px;
}

.confirm-dialog-text h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.375rem;
}

.confirm-dialog-text p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.confirm-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.75rem 1.5rem;
  border-top: 0.5px solid var(--border-light);
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  background: white;
  border: 0.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-box);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.25s ease-out;
}

.toast.toast-success {
  border-left: 3px solid #10b981;
}

.toast.toast-error {
  border-left: 3px solid var(--danger);
}

.toast.toast-info {
  border-left: 3px solid var(--accent-blue);
}

.toast.toast-warning {
  border-left: 3px solid var(--primary-hover);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast > span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.toast.toast-success .toast-icon { color: #10b981; }
.toast.toast-error .toast-icon { color: var(--danger); }
.toast.toast-info .toast-icon { color: var(--accent-blue); }
.toast.toast-warning .toast-icon { color: var(--primary-hover); }

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text-main); }
.toast-close svg, .toast-close i { width: 14px; height: 14px; }

.toast.toast-out {
  animation: toastOut 0.2s ease-in forwards;
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(4px) scale(0.97); }
}

/* Shared non-quiz component styles moved to `lib/shared-components.css` */

/* Slider Editor Item */
.slider-item-editor {
  background: var(--bg-box);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.slider-item-header,
.flipcard-item-header,
.iconcard-item-header,
.array-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-item-preview {
  max-width: 120px;
  max-height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* Shared non-quiz component styles moved to `lib/shared-components.css` */

/* Icon Cards Editor */
.iconcard-item-editor {
  background: var(--bg-box);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}



.iconcard-icon-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.iconcard-icon-row select {
  flex: 1;
}

.iconcard-icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.iconcard-icon-preview svg,
.iconcard-icon-preview i {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Imagine Agent – Lerngrafiken View
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Kursplaner View ────────────────────────────────────────────────────── */

.courseplan-view {
  flex: 1;
  width: 100%;
  height: calc(100vh - 64px);
  overflow: hidden;
  background: var(--bg-app);
}

.courseplan-view-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.courseplan-view-sidebar {
  background: #fff;
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.courseplan-sidebar-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.courseplan-result-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.courseplan-result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0;
}

.courseplan-result-actions .btn-block {
  width: 100%;
  justify-content: center;
}

.courseplan-sidebar-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.25rem 0;
}

.courseplan-revision-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.courseplan-revision-section .form-hint-text {
  margin-bottom: 0.75rem;
}

.courseplan-revision-section textarea {
  margin-bottom: 0.75rem;
}

.courseplan-revision-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.courseplan-revise-progress {
  margin-top: 0.75rem;
  gap: 0.25rem;
}

.courseplan-view-main {
  overflow-y: auto;
  padding: 2rem;
  min-width: 0;
  min-height: 0;
}

.courseplan-titelbild-result {
  max-width: 720px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.courseplan-titelbild-result img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

.btn.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.courseplan-result-content {
  max-width: 720px;
  margin: 0 auto;
}

.courseplan-section {
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.courseplan-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.courseplan-section-title i,
.courseplan-section-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.courseplan-welcome-text {
  line-height: 1.7;
  color: var(--text-main);
}

.courseplan-objectives {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.courseplan-objectives li {
  margin-bottom: 0.375rem;
  line-height: 1.5;
}

.courseplan-chapter {
  margin-bottom: 1rem;
}

.courseplan-chapter:last-child {
  margin-bottom: 0;
}

.courseplan-chapter-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-light);
}

.courseplan-lessons {
  padding-left: 0.75rem;
}

.courseplan-lesson {
  margin-bottom: 0.75rem;
}

.courseplan-lesson:last-child {
  margin-bottom: 0;
}

.courseplan-lesson-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.courseplan-keypoints {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.courseplan-keypoints li {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.125rem;
  line-height: 1.5;
}

.courseplan-duration {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.courseplan-duration i,
.courseplan-duration svg {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

@media (max-width: 900px) {
  .courseplan-view {
    height: auto;
    overflow-y: auto;
  }
  .courseplan-view-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .courseplan-view-sidebar {
    order: 2;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border-light);
  }
  .courseplan-view-main {
    order: 1;
    padding: 1rem;
    overflow: visible;
  }
  .courseplan-result-actions .btn-block {
    min-height: 44px;
  }
}

/* ── Imagine View ──────────────────────────────────────────────────────── */

.imagine-view {
  flex: 1;
  width: 100%;
  height: calc(100vh - 64px);
  overflow: hidden;
  background: var(--bg-app);
}

.imagine-view-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.imagine-view-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.imagine-result-image-wrap {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-box);
  overflow: hidden;
  line-height: 0;
  max-width: 100%;
  max-height: 100%;
}

.imagine-result-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.imagine-view-sidebar {
  background: #fff;
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.imagine-sidebar-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.imagine-result-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.imagine-result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0;
}

.imagine-result-actions .btn-block {
  width: 100%;
  justify-content: center;
}

.imagine-sidebar-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.25rem 0;
}

.imagine-iteration-section {
  margin-bottom: 0;
}

.imagine-iteration-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.imagine-iteration-section .form-hint-text {
  margin-bottom: 0.75rem;
}

.imagine-iteration-section textarea {
  margin-bottom: 0.75rem;
}

.imagine-iteration-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.imagine-iter-progress {
  margin-top: 0.75rem;
  gap: 0.25rem;
}

.ai-step-compact {
  padding: 0.375rem 0;
}

.ai-step-compact .ai-step-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
}

.ai-step-compact .ai-step-icon i,
.ai-step-compact .ai-step-icon svg {
  width: 14px;
  height: 14px;
}

.ai-step-compact .ai-step-title {
  font-size: 0.8125rem;
}

/* Responsive: Vertikaler Umbruch analog zum Editor-View */

@media (max-width: 900px) {
  .imagine-view {
    height: auto;
    overflow-y: auto;
  }
  .imagine-view-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .imagine-view-sidebar {
    order: 2;
    width: 100%;
    border-right: none;
    border-top: 1px solid var(--border-light);
  }
  .imagine-view-main {
    order: 1;
    padding: 1rem;
    overflow: visible;
  }
  .imagine-result-img {
    max-width: 100%;
    max-height: 60vh;
  }
  .imagine-result-actions .btn-block,
  .imagine-iteration-actions .btn-block {
    min-height: 44px;
  }
}

/* ── Imagine Editor Inline (Image Component Editor) ─────────────────── */
.imagine-editor-trigger .btn {
  gap: 0.4rem;
}
/* ── Image-picker button row (Upload + KI nebeneinander) ───────── */
.image-picker-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.imagine-editor-inline {
  background: var(--background-light, #f8f9fa);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}
/* Direkt unter Upload/URL/KI-Buttons wie das URL-Feld; Abstand kommt vom .image-picker gap */
.image-picker > .imagine-editor-inline {
  margin-top: 0;
  margin-bottom: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.imagine-editor-inline > .imagine-modal-form {
  margin-bottom: 0.5rem;
}
/* Kompakte Beschreibungs-Textarea (Editor-Inline vs. Modal ai-textarea) */
.imagine-prompt-textarea--compact {
  min-height: 5rem;
  max-height: 14rem;
  resize: vertical;
  font-size: 0.875rem;
  line-height: 1.5;
}
.imagine-editor-actions {
  display: flex;
  gap: 0.5rem;
}
.imagine-editor-progress {
  margin-top: 0.5rem;
}

/* ── Switch Row (label left, toggle right) ────────────────────────── */
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}
.switch-toggle {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light, #d1d5db);
  border-radius: 12px;
  transition: background 0.2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch-toggle input:checked + .switch-slider {
  background: var(--primary, #f5c518);
}
.switch-toggle input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch-toggle input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary, #f5c518);
  outline-offset: 2px;
}
