/* Reset & Box Sizing */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* CSS-переменные с поддержкой тем Telegram WebApp */
:root {
  --tg-theme-bg-color: #0f141c;
  --tg-theme-secondary-bg-color: #182232;
  --tg-theme-text-color: #f5f7fa;
  --tg-theme-hint-color: #8a9aa8;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;

  --bg-color: var(--tg-theme-bg-color, #0f141c);
  --secondary-bg-color: var(--tg-theme-secondary-bg-color, #182232);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-color: var(--tg-theme-text-color, #f5f7fa);
  --hint-color: var(--tg-theme-hint-color, #8a9aa8);
  --button-color: var(--tg-theme-button-color, #2481cc);
  --button-text-color: var(--tg-theme-button-text-color, #ffffff);

  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);

  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Автоматическая адаптация для светлой темы Telegram */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --tg-theme-bg-color: #f4f6f8;
    --tg-theme-secondary-bg-color: #ffffff;
    --tg-theme-text-color: #1c2530;
    --tg-theme-hint-color: #707579;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
  }
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  line-height: 1.45;
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-color);
}

/* Header & Progress */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 16px 8px;
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--button-color);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--card-bg);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--accent-color);
}

.step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint-color);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.progress-bar-wrapper {
  height: 4px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), #60a5fa);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Main & Screens */
.app-main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fadeIn 0.25s ease-out forwards;
}

.screen-active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-intro {
  margin-bottom: 20px;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.screen-subtitle {
  font-size: 14px;
  color: var(--hint-color);
  line-height: 1.4;
}

/* Экран 1: Карточки выбора источника */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  color: var(--text-color);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  position: relative;
  outline: none;
  width: 100%;
}

.action-card:hover:not(.card-disabled) {
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.action-card:focus-visible {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.card-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.card-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 14px;
}

.ready-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.draft-icon {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.voice-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.card-content {
  flex: 1;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
}

.card-description {
  font-size: 13px;
  color: var(--hint-color);
  margin-top: 3px;
  line-height: 1.35;
}

.badge-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--hint-color);
  text-transform: uppercase;
}

.card-arrow {
  color: var(--hint-color);
  margin-left: 10px;
  display: flex;
  align-items: center;
}

/* Формы и поля */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint-color);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-textarea {
  width: 100%;
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  color: var(--text-color);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: var(--transition);
}

.form-textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Радио-кнопки в виде плашек */
.radio-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-pill-label {
  flex: 1;
  min-width: calc(50% - 4px);
  cursor: pointer;
  position: relative;
}

.radio-pill-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  color: var(--hint-color);
  transition: var(--transition);
  text-align: center;
  height: 100%;
}

.radio-pill-label input:checked + .radio-pill-content {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-color);
  color: var(--text-color);
  font-weight: 600;
}

.radio-pill-label input:focus-visible + .radio-pill-content {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* Свитч-переключатель */
.toggle-group {
  margin-top: 10px;
}

.switch-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 12px;
  user-select: none;
}

.switch-container input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  transition: var(--transition);
  flex-shrink: 0;
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: var(--transition);
}

.switch-container input:checked + .switch-slider {
  background-color: var(--accent-color);
}

.switch-container input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch-container input:focus-visible + .switch-slider {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.switch-label-text {
  font-size: 14px;
  color: var(--text-color);
}

/* Ползунок количества слайдов */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-value-badge {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-color);
}

.slider-control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-bound {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint-color);
  width: 16px;
}

.range-slider {
  flex: 1;
  accent-color: var(--accent-color);
  height: 6px;
  background: var(--card-border);
  border-radius: 3px;
  outline: none;
}

.form-hint {
  font-size: 12px;
  color: var(--hint-color);
  margin-top: 6px;
}

/* Информационные баннеры */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--border-radius-sm);
  background-color: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  margin: 16px 0 20px;
}

.neutral-banner {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--card-border);
}

.banner-icon {
  flex-shrink: 0;
  color: var(--accent-color);
  margin-top: 2px;
}

.neutral-banner .banner-icon {
  color: var(--hint-color);
}

.banner-text {
  font-size: 13px;
  color: var(--text-color);
  line-height: 1.4;
}

/* Кнопки */
.screen-actions {
  margin-top: auto;
  padding-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--button-color);
  color: var(--button-text-color);
  box-shadow: 0 4px 12px rgba(36, 129, 204, 0.25);
}

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

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background-color: var(--secondary-bg-color);
  color: var(--text-color);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  border-color: var(--accent-color);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* Экран 3: Редактор слайдов */
.intro-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.slides-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.slide-editor-card {
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}

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

.slide-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-hook {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-content {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-cta {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.slide-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-slide-action {
  background: none;
  border: none;
  color: var(--hint-color);
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-slide-action:hover:not(:disabled) {
  color: var(--text-color);
  background-color: var(--card-bg);
}

.btn-slide-action:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.btn-delete:hover:not(:disabled) {
  color: var(--danger-color);
  background-color: var(--danger-bg);
}

.slide-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--hint-color);
}

.char-counter {
  font-size: 11px;
  font-weight: 500;
  color: var(--hint-color);
}

.char-counter.limit-exceeded {
  color: var(--danger-color);
  font-weight: 700;
}

.slide-input-title {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-color);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  outline: none;
  transition: var(--transition);
}

.slide-input-title:focus {
  border-color: var(--accent-color);
}

.slide-input-title.has-error, .slide-input-body.has-error {
  border-color: var(--danger-color);
  background-color: var(--danger-bg);
}

.slide-input-body {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-color);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 8px 12px;
  resize: vertical;
  min-height: 70px;
  outline: none;
  transition: var(--transition);
}

.slide-input-body:focus {
  border-color: var(--accent-color);
}

.field-warning-msg {
  font-size: 11px;
  color: var(--danger-color);
  display: none;
}

.field-warning-msg.show {
  display: block;
}

.field-hint {
  margin-top: 6px;
  color: var(--hint-color);
  font-size: 11px;
  line-height: 1.35;
}

.editor-bottom-controls {
  margin: 8px 0 16px;
}

/* Экран 4: Выбор шаблона */
.template-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.template-card {
  background-color: var(--secondary-bg-color);
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.template-card:hover {
  transform: translateY(-2px);
}

.template-card.selected {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.template-card:focus-visible {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.template-preview {
  height: 140px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.preview-expert-dark {
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
}

.preview-minimal-light {
  background: linear-gradient(135deg, #f0f2f5 0%, #e2e8f0 100%);
}

.preview-vibrant-accent {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}

.tmpl-slide-mini {
  width: 180px;
  height: 110px;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.preview-expert-dark .tmpl-slide-mini {
  background-color: #121824;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.preview-minimal-light .tmpl-slide-mini {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

.preview-vibrant-accent .tmpl-slide-mini {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.tmpl-tag {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.preview-expert-dark .tmpl-tag { color: #60a5fa; }
.preview-minimal-light .tmpl-tag { color: #2563eb; }
.preview-vibrant-accent .tmpl-tag { color: #fde047; }

.tmpl-title-line {
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

.tmpl-body-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
}

.tmpl-line {
  height: 4px;
  border-radius: 2px;
  width: 100%;
}

.preview-expert-dark .tmpl-line { background: rgba(255, 255, 255, 0.2); }
.preview-minimal-light .tmpl-line { background: rgba(0, 0, 0, 0.15); }
.preview-vibrant-accent .tmpl-line { background: rgba(255, 255, 255, 0.35); }

.tmpl-line.short {
  width: 65%;
}

.tmpl-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  opacity: 0.7;
}

.template-info {
  padding: 14px 16px;
  background-color: var(--secondary-bg-color);
}

.template-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.template-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
}

.template-check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background-color: var(--accent-color);
  opacity: 0;
  transform: scale(0.6);
  transition: var(--transition);
}

.template-card.selected .template-check-icon {
  opacity: 1;
  transform: scale(1);
}

.template-desc {
  font-size: 13px;
  color: var(--hint-color);
  line-height: 1.35;
}

/* Экран 5: Подтверждение и сборка */
.summary-card {
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.summary-label {
  color: var(--hint-color);
}

.summary-value {
  font-weight: 600;
  color: var(--text-color);
  text-align: right;
}

.warnings-card {
  background-color: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.warnings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 10px;
}

.warnings-list {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.build-status-card {
  background-color: var(--secondary-bg-color);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.status-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--hint-color);
  transition: var(--transition);
}

.status-step-item.active {
  color: var(--text-color);
  font-weight: 600;
}

.status-step-item.done {
  color: var(--success-color);
}

.status-step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--hint-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-step-item.active .status-step-icon {
  border-color: var(--accent-color);
}

.status-step-item.done .status-step-icon {
  border-color: var(--success-color);
  background-color: var(--success-color);
  color: #ffffff;
}

.spinner-mini {
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.demo-success-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--card-border);
  text-align: center;
}

.success-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.success-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 6px;
}

.success-description {
  font-size: 13px;
  color: var(--hint-color);
  line-height: 1.4;
}

.app-notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.45;
}

.app-notice.error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
}

.form-help {
  margin-top: 8px;
  color: var(--hint-color);
  font-size: 12px;
  line-height: 1.4;
}

.result-files {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--hint-color);
  font-size: 13px;
}

.result-files li + li { margin-top: 4px; }

/* ==========================================================================
   Экран 4: Модульный конструктор оформления и живой предпросмотр
   ========================================================================== */

.style-preview-container {
  margin-bottom: 20px;
}

.style-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}

.preview-badge {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-color);
}

.preview-caption {
  color: var(--hint-color);
  font-size: 11px;
}

.modular-preview-card {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 280px;
  border-radius: var(--border-radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  border: 1px solid var(--card-border);
  transition: var(--transition);
}

.modular-preview-card.bg-dark-blue {
  background: radial-gradient(circle at 85% 15%, rgba(37, 99, 235, 0.22) 0%, rgba(13, 18, 28, 0) 65%), linear-gradient(180deg, #101623 0%, #0a0d14 100%);
  color: #f8fafc;
}

.modular-preview-card.bg-light-paper {
  background: linear-gradient(180deg, #fbfbf9 0%, #f5f5f0 100%);
  color: #1e3a8a;
}

.modular-preview-card.bg-vibrant-gradient {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: #ffffff;
}

.preview-bg-accent {
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background-image: radial-gradient(rgba(59, 130, 246, 0.18) 1.5px, transparent 1.5px);
  background-size: 12px 12px;
  opacity: 0.7;
  pointer-events: none;
}

.modular-preview-card.bg-light-paper .preview-bg-accent,
.modular-preview-card.bg-vibrant-gradient .preview-bg-accent {
  display: none;
}

.modular-preview-card.font-noto-sans {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.modular-preview-card.font-serif {
  font-family: 'Playfair Display', Georgia, Cambria, 'Times New Roman', serif;
}

.modular-preview-card.font-handwritten {
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
}

.preview-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
}

.preview-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modular-preview-card.bg-dark-blue .preview-tag { color: #60a5fa; }
.modular-preview-card.bg-light-paper .preview-tag { color: #2563eb; }
.modular-preview-card.bg-vibrant-gradient .preview-tag { color: #fde047; }

.preview-counter {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.1);
}

.modular-preview-card.bg-light-paper .preview-counter {
  background: rgba(30, 58, 138, 0.08);
  color: #1e3a8a;
}

.preview-content-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 2;
  margin: 10px 0;
}

.modular-preview-card.layout-centered .preview-content-box {
  align-items: center;
  text-align: center;
}

.modular-preview-card.layout-editorial .preview-title {
  border-bottom: 2px solid currentColor;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.preview-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 6px;
}

.modular-preview-card.font-handwritten .preview-title {
  font-size: 18px;
  line-height: 1.4;
}

.preview-body {
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.9;
}

.modular-preview-card.font-handwritten .preview-body {
  font-size: 13px;
  line-height: 1.5;
}

.preview-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 10px;
  font-weight: 600;
  z-index: 2;
}

.modular-preview-card.bg-light-paper .preview-footer-bar {
  border-top-color: rgba(30, 58, 138, 0.15);
}

.preview-author {
  opacity: 0.8;
}

.preview-swipe {
  font-size: 9px;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   PRESET CARDS GALLERY (Screen 4)
   ========================================================================== */

.presets-gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background-color: var(--secondary-bg-color);
  border: 2px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  position: relative;
}

.preset-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.preset-card.active {
  border-color: var(--accent-color);
  background-color: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.preset-card:focus-visible {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* Card mini preview widget */
.preset-card-mini-preview {
  width: 76px;
  height: 95px; /* 4:5 aspect ratio */
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 6px;
}

.preset-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
}

.preset-card-desc {
  font-size: 12px;
  color: var(--hint-color);
  line-height: 1.35;
}

.preset-card-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
  transition: var(--transition);
}

.preset-card.active .preset-card-check {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: #ffffff;
}

/* Mini preview themes & styles */
.preview-family-expert-dark {
  background: radial-gradient(circle at 88% 8%, rgba(228, 90, 53, 0.34) 0%, rgba(24, 21, 20, 0) 65%), #171313;
  color: #fff8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.preview-family-expert-dark .mini-tag { font-size: 5px; font-weight: 700; color: #e45a35; }
.preview-family-expert-dark .mini-title { font-size: 9px; font-family: Impact, "Arial Narrow", sans-serif; font-weight: 800; line-height: 1.05; color: #fff8f0; }
.preview-family-expert-dark .mini-footer { font-size: 5px; color: #b6a79a; display: flex; justify-content: space-between; }

.preview-family-handwritten-paper {
  background: linear-gradient(180deg, #fbfbf9 0%, #f4f4ee 100%);
  color: #1e3a8a;
  border: 1px solid #cbd5e1;
}
.preview-family-handwritten-paper .mini-tag { font-size: 5px; font-weight: 700; color: #2563eb; }
.preview-family-handwritten-paper .mini-title { font-size: 8px; font-weight: 600; font-family: 'Caveat', cursive, fantasy; line-height: 1.2; color: #1e3a8a; }
.preview-family-handwritten-paper .mini-footer { font-size: 5px; color: #2563eb; display: flex; justify-content: space-between; }

.preview-family-mega-numeral {
  background: radial-gradient(circle at 92% 6%, rgba(237, 156, 87, 0.28) 0%, rgba(54, 25, 29, 0) 42%), linear-gradient(150deg, #311b20 0%, #171113 100%);
  color: #fff3df;
  border: 1px solid rgba(243, 181, 98, 0.3);
}
.preview-family-mega-numeral .mini-numeral { font-size: 17px; font-family: Impact, "Arial Narrow", sans-serif; font-weight: 900; color: #e76f51; line-height: 1; }
.preview-family-mega-numeral .mini-title { font-size: 8px; font-family: Impact, "Arial Narrow", sans-serif; font-weight: 700; color: #fff3df; }
.preview-family-mega-numeral .mini-footer { font-size: 5px; color: #caaea5; display: flex; justify-content: space-between; }

.preview-family-split {
  background: #eee1d0;
  color: #25211f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px;
}
.preview-family-split .mini-split-header { font-size: 5px; font-weight: 700; color: #c94d34; margin-bottom: 2px; }
.preview-family-split .mini-split-panel { background: #fffaf2; border-radius: 4px; padding: 4px; flex: 1; display: flex; align-items: center; }
.preview-family-split .mini-title { font-size: 8px; font-family: Impact, "Arial Narrow", sans-serif; font-weight: 800; color: #25211f; }

.preview-family-cards {
  background: radial-gradient(ellipse at 18% 5%, #f1c9a7 0%, #d9926d 48%, #b55f48 100%);
  color: #2b1d19;
  border: 1px solid rgba(84, 42, 33, 0.22);
  padding: 5px;
}
.preview-family-cards .mini-card-box {
  background: rgba(255, 246, 235, 0.84);
  border: 1px solid rgba(84, 42, 33, 0.2);
  border-radius: 6px;
  padding: 4px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.preview-family-cards .mini-tag { font-size: 5px; color: #8f3026; }
.preview-family-cards .mini-title { font-size: 7px; font-family: Georgia, serif; font-weight: 700; color: #2b1d19; }

.preview-family-progress {
  background: linear-gradient(160deg, #26211f 0%, #131111 100%);
  color: #fff7ed;
  border: 1px solid rgba(255, 247, 237, 0.14);
}
.preview-family-progress .mini-progress-bar { display: flex; gap: 2px; margin-bottom: 2px; }
.preview-family-progress .mini-progress-bar span { width: 8px; height: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.2); }
.preview-family-progress .mini-progress-bar span.active { background: #e76f51; }
.preview-family-progress .mini-title { font-size: 8px; font-family: Impact, "Arial Narrow", sans-serif; font-weight: 700; color: #fff7ed; }
.preview-family-progress .mini-footer { font-size: 5px; color: #baa89a; display: flex; justify-content: space-between; }
