/* /public/css/editor.css */

/* Design tokens needed by BEM components */
@import url('./modern/variables.css');

/* BEM Components used in editors */
@import url('./components/modal.css');
@import url('./components/forms.css');
@import url('./components/alert.css');
@import url('./components/editor/forms.css');

/* ====================
   CSS CUSTOM PROPERTIES
   ==================== */

:root {
  /* Card backgrounds */
  --card-bg: #F8FAFC;
  --card-bg-nested: #FAFAFA;
  --card-bg-white: var(--app-white);

  /* Borders */
  --card-border: var(--app-gray-200);
  --card-border-light: #F1F5F9;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Spacing */
  --card-padding: 12px;
  --card-padding-nested: 10px;
  --card-gap: 8px;

  /* Typography scale for titles */
  --text-title-lg: 15px;
  --text-title-md: 13px;
  --text-title-sm: 12px;

  /* Text colors */
  --text-muted: var(--app-gray-500-g);
  --text-label: var(--app-gray-500);
  --text-primary: var(--app-gray-800-g);

  /* Accent colors */
  --accent-blue: var(--app-blue-400);
  --accent-blue-light: rgba(59, 130, 246, 0.7);
}

/* ====================
   LAYOUT CONTAINERS
   ==================== */

#editor-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  width: 100vw;
  max-width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
}

#editor-header {
  align-items: center;
  background-color: var(--app-white);
  border-bottom: 1px solid var(--editor-border);
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  gap: 8px;
  height: 60px;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

#editor-header .header-left {
  align-items: center;
  align-content: stretch;
  display: flex;
  flex-direction: row;
  gap: 8px;
  line-height: 1.5rem;
}

#editor-header .header-logo {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

#editor-header .header-logo:hover {
  background-color: var(--app-gray-100-g);
}

#editor-header .header-logo img {
  height: 34px;
  width: auto;
}

#editor-header .header-right {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

/* History Controls (Undo/Redo) */
.history-controls {
  display: flex;
  gap: 4px;
  margin-right: 8px;
}

.history-controls .btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--app-gray-300-g);
  background: var(--app-white);
  color: var(--app-gray-700-g);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.history-controls .btn-icon:hover:not(:disabled) {
  background: var(--app-gray-50-g);
  border-color: var(--app-gray-400-g);
  color: var(--app-gray-800-g);
}

.history-controls .btn-icon:active:not(:disabled) {
  background: var(--app-gray-100-g);
  border-color: var(--app-gray-400-g);
  box-shadow: none;
}

.history-controls .btn-icon:disabled,
.history-controls .btn-icon.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--app-gray-50-g);
  color: var(--app-gray-400-g);
}

.history-controls .btn-icon svg {
  width: 16px;
  height: 16px;
}

/* Save Controls (Save Status + Version History) */
.save-controls {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.save-status-btn {
  height: 36px;
  width: 100px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition:
    background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.save-status-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.save-status-btn:active:not(:disabled):not(.save-status-btn--saving) {
  transform: scale(0.98);
}

.save-status-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.save-status-btn__icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.save-status-btn__text {
  transition: opacity 0.15s ease;
}

/* ===== Saving State ===== */
.save-status-btn--saving {
  background: #F8FAFC;
  border: 1px solid var(--app-gray-200);
  color: var(--app-gray-500);
  cursor: default;
  pointer-events: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.save-status-btn--saving svg {
  animation: save-spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes save-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ===== Saved State ===== */
.save-status-btn--saved {
  background: #F8FAFC;
  border: 1px solid var(--app-gray-200);
  color: var(--app-gray-500);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.save-status-btn--saved svg {
  color: #22C55E;
}

.save-status-btn--saved:hover {
  background: #F1F5F9;
  border-color: var(--app-gray-300);
  color: var(--app-gray-600);
}

.save-status-btn--saved:hover svg {
  transform: scale(1.1);
}

/* ===== Error State ===== */
.save-status-btn--error {
  background: var(--app-red-50);
  border: 1px solid var(--app-red-200);
  color: var(--app-red-600);
  box-shadow:
    0 1px 2px rgba(220, 38, 38, 0.08),
    0 0 0 3px rgba(220, 38, 38, 0.08);
  animation: save-error-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.save-status-btn--error:hover {
  background: #FEE2E2;
  border-color: #FCA5A5;
  color: #B91C1C;
  box-shadow:
    0 1px 3px rgba(220, 38, 38, 0.12),
    0 0 0 3px rgba(220, 38, 38, 0.1);
}

.save-status-btn--error svg {
  animation: save-error-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) 1;
}

@keyframes save-error-pulse {

  0%,
  100% {
    box-shadow:
      0 1px 2px rgba(220, 38, 38, 0.08),
      0 0 0 3px rgba(220, 38, 38, 0.08);
  }

  50% {
    box-shadow:
      0 1px 2px rgba(220, 38, 38, 0.08),
      0 0 0 4px rgba(220, 38, 38, 0.04);
  }
}

@keyframes save-error-shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-2px);
  }

  40% {
    transform: translateX(2px);
  }

  60% {
    transform: translateX(-1px);
  }

  80% {
    transform: translateX(1px);
  }
}

/* Version History Button */
.version-history-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--app-gray-300-g);
  background: var(--app-white);
  color: var(--app-gray-700-g);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.version-history-btn:hover:not(:disabled) {
  background: var(--app-gray-50-g);
  border-color: var(--app-gray-400-g);
  color: var(--app-gray-800-g);
}

.version-history-btn:active:not(:disabled) {
  background: var(--app-gray-100-g);
  border-color: var(--app-gray-400-g);
  box-shadow: none;
}

.version-history-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.version-history-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--app-gray-50-g);
  color: var(--app-gray-400-g);
}

.version-history-btn svg {
  width: 16px;
  height: 16px;
}

/* Responsive: Hide save status text on smaller screens */
@media (max-width: 900px) {
  .save-status-btn {
    width: 36px;
    padding: 0;
  }

  .save-status-btn .save-status-btn__text {
    display: none;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .save-status-btn--saving svg {
    animation: none;
  }

  .save-status-btn--error {
    animation: none;
  }

  .save-status-btn,
  .version-history-btn {
    transition: none;
  }
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--app-gray-200-g);
  margin: 0 8px;
}

/* Document Name */
#document-name {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  /* Allow shrinking if needed */
}

/* Editable Name Input */
#editor-header input.editable-name {
  border: 1px solid transparent;
  border-radius: 8px;
  color: #333;
  font-size: 1.25rem;
  font-weight: 500;
  padding: 8px 10px;
  transition: color 0.3s ease-in-out, border 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
  min-width: 200px;
  width: auto;
  max-width: 100%;
  field-sizing: content;
  /* Modern browsers: auto-size to content */
}

#editor-header input.editable-name:hover,
#editor-header input.editable-name:focus-visible {
  border: 1px solid #eee;
  box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.05);
}

#editor-header input.editable-name:focus-visible {
  color: var(--color-primary);
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ====================
   MAIN EDITOR LAYOUT
   ==================== */

#editor-main {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar Base Styles */
.sidebar {
  align-items: stretch;
  background-color: var(--app-white);
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
}

#sidebar-left {
  border-right: 1px solid var(--editor-border);
  min-width: 160px;
  width: 240px;
  overflow-y: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

#sidebar-right {
  border-left: 1px solid var(--editor-border);
  min-width: 350px;
  width: 400px;
  overflow-y: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: width 250ms ease-out, min-width 250ms ease-out, opacity 200ms ease-out, border 250ms ease-out;
}

#sidebar-right.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  border-left: none;
  pointer-events: none;
}

/* Scrollable content area within right sidebar */
.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 0;
}

/* Fixed footer for action buttons (Save, etc.) */
.sidebar-footer {
  flex-shrink: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--editor-border);
  background-color: #FAFAFA;
}

.sidebar-footer.hidden {
  display: none;
}

.sidebar-footer .btn {
  width: 100%;
}

/* Sidebar Typography */
.sidebar h2 {
  flex: 1;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.25rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.sidebar h3 {
  color: #333;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 100%;
  margin: 0;
}

/* Sidebar Title Bar */
.sidebar-title {
  align-items: center;
  display: flex;
  gap: 4px;
  height: 52px;
  justify-content: space-between;
  position: relative;
}

#sidebar-left .sidebar-title {
  padding: 12px 20px 8px;
}

#sidebar-right .sidebar-title {
  padding: 12px 0 8px;
}

/* Sidebar Action Button */
.sidebar-action {
  padding: 0 20px 12px;
  position: relative;
}

/* Button styles are now in /css/buttons.css */

/* Editor-specific button overrides */
.sidebar-action .btn-block {
  justify-content: flex-start;
  padding: 8px 12px;
  font-size: 0.8125rem;
}

.sidebar-action .btn-block svg {
  flex-shrink: 0;
}

/* Dropdown positioning for sidebar action */
.sidebar-action .dropdown {
  top: 100%;
  left: 20px;
  right: 20px;
  width: auto;
  transform: none;
  margin-top: 4px;
}

.sidebar-action .dropdown-arrow {
  display: none;
}

/* ====================
   STRUCTURE LIST STYLES
   ==================== */

/* Structure List Container */
#structure-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  margin: 0;
}

/* Structure Item */
#structure-list .structure-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background-color: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

/* Structure Icon */
#structure-list .structure-item .structure-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--app-gray-400);
  flex-shrink: 0;
  transition: color 150ms ease;
}

/* Structure Title */
#structure-list .structure-item .structure-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  transition: color 150ms ease;
}

/* Hover State */
#structure-list .structure-item:hover {
  background-color: var(--app-gray-50);
  border-color: var(--app-gray-200);
}

#structure-list .structure-item:hover .structure-title {
  color: var(--app-gray-900);
}

#structure-list .structure-item:hover .structure-icon {
  color: var(--app-gray-600);
}

/* Selected/Active State */
#structure-list .structure-item.active {
  background-color: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

#structure-list .structure-item.active .structure-title {
  color: var(--app-primary-dark);
  font-weight: 600;
}

#structure-list .structure-item.active .structure-icon {
  color: var(--app-primary);
}

/* Focus State (Keyboard Navigation) */
#structure-list .structure-item:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ====================
   MODULE LIST STYLES - MODERNIZED
   ==================== */

/* Module List Container */
#module-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0 4px 12px;
  list-style: none;
  margin: 0;
  transition: background-color 150ms ease, padding 150ms ease;
}

#module-list.drag-active {
  background-color: var(--app-gray-50);
  border-radius: var(--radius-md);
}

/* Base Module Item */
#module-list .module {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background-color: var(--app-gray-50);
  border: 1px solid var(--app-gray-100);
  cursor: pointer;
  position: relative;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 100ms ease;
}

/* Drag Handle - Always Visible */
#module-list .module .module-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 17px;
  border-radius: 4px;
  color: var(--app-gray-300);
  cursor: grab;
  flex-shrink: 0;
  transition: color 150ms ease, background-color 150ms ease, transform 100ms ease;
}

#module-list .module .module-drag-handle:hover {
  color: var(--app-gray-500);
  background-color: var(--app-gray-100);
}

#module-list .module .module-drag-handle:active {
  cursor: grabbing;
  color: var(--app-primary);
  transform: scale(0.95);
}

/* Module Content Area */
#module-list .module .module-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* Module Title */
#module-list .module .module-title {
  font-size: 13px;
  font-weight: 400;
  color: var(--app-gray-700);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  transition: color 150ms ease;
}

/* ===== INTERACTIVE STATES ===== */

/* Hover State */
#module-list .module:hover {
  background-color: var(--app-gray-100);
  border-color: var(--app-gray-200);
}

#module-list .module:hover .module-title {
  color: var(--app-gray-900);
}

/* Selected/Active State */
#module-list .module.selected,
#module-list .module.active {
  background-color: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

#module-list .module.selected .module-title,
#module-list .module.active .module-title {
  color: var(--app-primary-dark);
  font-weight: 600;
}

#module-list .module.selected .module-drag-handle,
#module-list .module.active .module-drag-handle {
  color: var(--app-primary);
}

/* Focus State (Keyboard Navigation) */
#module-list .module:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ===== DRAG AND DROP STATES ===== */

/* Dragging State - Applied to item being dragged */
#module-list .module.sortable-drag {
  background-color: white;
  border-color: var(--app-primary);
  box-shadow:
    0 4px 12px rgba(37, 99, 235, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
  z-index: 100;
}

#module-list .module.sortable-drag .module-drag-handle {
  color: var(--app-primary);
  cursor: grabbing;
}

/* Ghost Element - Placeholder showing where item will drop */
#module-list .module.sortable-ghost {
  background-color: var(--app-gray-100);
  border: 2px dashed var(--app-primary);
  border-radius: var(--radius-md);
  opacity: 1;
}

#module-list .module.sortable-ghost>* {
  opacity: 0;
}

/* Chosen State - When item is picked up */
#module-list .module.sortable-chosen {
  background-color: rgba(37, 99, 235, 0.05);
}

/* ===== EDGE CASES ===== */

/* Empty state */
#module-list:empty::after {
  content: 'No modules yet. Click "New Module" to add one.';
  display: block;
  padding: 24px 16px;
  text-align: center;
  color: var(--app-gray-400);
  font-size: 13px;
}

/* Single module - subtle drag indicator */
#module-list .module:only-child .module-drag-handle {
  opacity: 0.4;
}

/* Saving state */
#module-list.saving .module {
  pointer-events: none;
  opacity: 0.7;
}

/* ===== ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {

  #module-list .module,
  #module-list .module *,
  #module-list {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ===== LEGACY COMPATIBILITY ===== */
/* Support for old HTML structure during transition */

#module-list .module .module-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#module-list .module .module-left img:first-child {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

#module-list .module .icon-move {
  display: block !important;
  width: 12px;
  height: 16px;
  opacity: 0.3;
  cursor: grab;
  transition: opacity 150ms ease;
}

#module-list .module:hover .icon-move {
  opacity: 0.6;
}

#module-list .module .icon-move:active {
  cursor: grabbing;
  opacity: 1;
}

/* ===== INTERACTIVE PREVIEW STYLES ===== */
/* Sidebar hover state synced from preview */
.module.hover {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: var(--app-blue-400);
}

/* ====================
   CONTENT AREAS
   ==================== */

/* Common container styles */
#sidebar-right .content-control,
#editor-content {
  display: flex;
  flex-direction: column;
}

#sidebar-right .content-control {
  gap: 16px;
}

#editor-content {
  gap: 12px;
}

#content-area {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  min-width: 0;
  overflow-y: auto;
}

/* ====================
   PREVIEW CONTROLS
   ==================== */

#email-preview-controls {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 0;
}

/* Control Groups (Device & Theme toggles) */
.preview-control-group {
  background-color: var(--app-gray-100-g);
  border-radius: 8px;
  display: flex;
  height: 36px;
  padding: 3px;
}

.preview-control-btn {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--app-gray-500-g);
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
  width: 38px;
}

.preview-control-btn:hover {
  color: var(--app-gray-700-g);
}

.preview-control-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.preview-control-btn.active {
  background-color: var(--app-white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: var(--color-primary);
}

.preview-control-btn svg {
  height: 18px;
  width: 18px;
}

/* Legacy support for old device-toggle structure */
#device-toggle {
  display: flex;
  height: 32px;
}

#device-toggle>div {
  align-items: center;
  border: 1px solid #DFDFDF;
  border-right: 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  width: 40px;
}

#device-toggle>div:hover,
#device-toggle>div.active {
  background-color: var(--app-white);
}

#device-toggle>div:first-child {
  border-radius: 8px 0 0 8px;
}

#device-toggle>div:last-child {
  border-right: 1px solid #DFDFDF;
  border-radius: 0 8px 8px 0;
}

#device-toggle>div.active svg {
  color: var(--color-primary);
}

#device-toggle div img {
  height: 20px;
  width: auto;
}

/* Preview Containers */
#email-preview-container,
#preview-container {
  background-color: var(--app-white);
  border: 1px solid var(--editor-border);
  flex: 1;
  position: relative;
  transition: width 0.3s ease-in-out, min-width 0.3s ease-in-out;
  min-width: 680px;
  width: 100%;
  margin: 0 auto;
}

#email-preview-container.tablet,
#preview-container.tablet {
  width: 768px;
  min-width: 768px;
}

#email-preview-container.mobile,
#preview-container.mobile {
  width: 390px;
  min-width: 375px;
}

#email-preview-iframe,
#preview-iframe {
  border: none;
  height: 100%;
  width: 100%;
}

/* ====================
   LOADING & UTILITY STYLES
   ==================== */

.loading-overlay {
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 75ms ease-out;
  width: 100%;
}

.loading-overlay.active {
  opacity: 1;
}

.spinner {
  animation: spin 500ms linear infinite;
  border: 6px solid #f3f3f3;
  border-top: 6px solid #3498db;
  border-radius: 50%;
  height: 40px;
  width: 40px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none;
}

#module-editor-placeholder {
  color: var(--app-gray-500-g);
  font-size: 0.875rem;
}

/* ====================
   FORM CONTROLS BASE
   ==================== */

label {
  font-size: 0.875rem;
  line-height: 100%;
}

/* ====================
   LIST STYLES
   ==================== */

/* Base module list styles */
#available-module-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#available-module-list {
  max-height: calc(80vh - 80px);
  overflow-y: auto;
}

#module-list li,
#available-module-list li {
  cursor: pointer;
  margin: 0;
  padding: 8px 12px;
}

#module-list li {
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
}

#module-list li:hover,
#available-module-list li:hover,
#available-module-list li:focus-visible {
  background-color: #f0f0f0;
}

#module-list li:last-child {
  border-bottom: none;
}

/* ====================
   DROPDOWN & POPOVER STYLES
   ==================== */

.button-wrapper {
  position: relative;
}

.dropdown {
  background-color: var(--app-white);
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  font-size: 0.75rem;
  margin-top: 10px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-20%);
  max-width: 400px;
  min-width: 200px;
  z-index: 999;
}

.dropdown.new-module {
  width: 400px;
}

.dropdown-arrow {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 10px solid #ffffff;
}

.dropdown-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.loading {
  color: #555;
  font-size: 16px;
  padding: 20px;
  text-align: center;
}

/* ====================
   MODULE PREVIEW DROPDOWN
   ==================== */

/* Override base dropdown constraints for module preview dropdown */
.sidebar-action .module-dropdown-with-preview {
  /* Override sidebar-action dropdown constraints */
  position: absolute;
  max-width: none !important;
  min-width: 640px !important;
  width: 640px;
  height: 556px;
  left: 20px !important;
  right: auto !important;
  transform: none !important;
  font-size: 0.875rem;
  z-index: 1001;
  isolation: isolate;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--app-gray-200-g);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Allow dropdown to overflow sidebar when open */
#sidebar-left.dropdown-open {
  overflow: visible !important;
}

#sidebar-left.dropdown-open .sidebar-action {
  overflow: visible;
}

.module-dropdown-with-preview.hidden {
  display: none !important;
}

.module-dropdown-with-preview:not(.hidden) {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

/* Module List Styling */
.module-dropdown-list {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--app-gray-200-g);
  box-sizing: border-box;
}

.module-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-gray-200-g);
  background: var(--app-gray-50-g);
}

.module-dropdown-header h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--app-gray-500-g);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin: 0;
}

.module-dropdown-list ul {
  max-height: 510px;
  /* Match preview panel height minus header (~46px) */
  overflow-y: auto;
  padding: 6px;
}

/* Override base list item styles for module dropdown */
.module-dropdown-with-preview #available-module-list li {
  padding: 10px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--app-gray-700-g);
  border-radius: 6px;
  margin: 0;
  transition: background-color 150ms ease;
}

.module-dropdown-with-preview #available-module-list li:hover,
.module-dropdown-with-preview #available-module-list li:focus-visible {
  background-color: var(--app-gray-100-g);
  color: var(--app-gray-800-g);
}

.module-dropdown-with-preview #available-module-list li:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: -2px;
}

/* Preview Panel - Always visible to the right of the list */
/* Stretches to fill the fixed-height dropdown */
.module-preview-panel {
  flex: 1;
  background: var(--app-gray-50-g);
  overflow: hidden;
  position: relative;
  border-radius: 0 7px 7px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hint text when no preview */
.module-preview-panel::before {
  content: 'Hover to preview';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  color: var(--app-gray-400-g);
  pointer-events: none;
  opacity: 1;
  transition: opacity 200ms ease;
  z-index: 1;
}

.module-preview-panel.has-preview::before {
  opacity: 0;
}

/* Inner frame/card for the preview */
.module-preview-frame {
  margin: 20px;
  background: var(--app-white);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px;
  width: 364px;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 150ms ease-in;
}

.module-preview-frame.visible {
  opacity: 1;
}

.module-preview-frame iframe {
  width: 600px;
  height: 540px;
  transform: scale(0.58);
  transform-origin: top center;
  border: none;
  pointer-events: none;
  background: var(--app-white);
  flex-shrink: 0;
}

#module-preview-cache {
  display: none !important;
  position: absolute;
  left: -9999px;
  visibility: hidden;
}

.module-preview-cached {
  display: none;
}

/* Notification system is defined in style.css - removed duplicate */

/* ====================
   MODAL STYLES
   Note: Modal styles are in /css/components/modal.css
   ==================== */

/* ====================
   FIELD & CARD COMPONENTS
   ==================== */

/* Base Field Container - no external margins, parent containers use gap */
.sidebar-card__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* Primary field label - used for main field names inside grouped containers */
.sidebar-card__field--grouped .sidebar-card__field-header label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ====================
   FIELD SETTINGS POPOVER
   ==================== */

.sidebar-card__field-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 12px;
}

.sidebar-card__field-header label {
  margin-bottom: 0;
  flex: 1;
}

/* Toggle switch in field header - keep it compact and right-aligned */
.sidebar-card__field-header .toggle-switch {
  flex: 0 0 auto;
  margin-left: auto;
  margin-right: 2px; /* Room for focus outline (2px outline + 2px offset) */
}

/* Input wrapper — positions icon button inside the input */
.sidebar-card__input-wrap {
  position: relative;
}

/* Icon button inside the input */
.sidebar-card__input-wrap > .ai-generate-btn {
  position: absolute;
  right: 8px;
  top: 8px;
}

/* Add right padding to input when it has an icon button inside */
.input-field--has-icon {
  padding-right: 32px;
}

.field-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--app-gray-400);
  cursor: pointer;
  opacity: 1;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

/* Settings button in field header row (template editor single fields) */
.field-settings-btn--card {
  /* No extra margin - label flex: 1 pushes buttons right */
}

/* Show settings button on hover of parent containers */
.sidebar-card__title-row:hover .field-settings-btn,
.sidebar-card__field:hover .field-settings-btn,
.sidebar-card--nested:hover .field-settings-btn--card {
  opacity: 1;
}

.field-settings-btn svg {
  transition: transform 0.2s ease;
}

.field-settings-btn:hover {
  color: var(--app-gray-500);
}

.field-settings-btn:hover svg {
  transform: rotate(45deg);
}

.field-settings-btn.active {
  color: var(--color-primary, var(--app-blue-link));
  opacity: 1;
}

.field-settings-btn.active svg {
  transform: rotate(90deg);
}

/* Inline field settings panel — base styles (overridden by .field-panel-card when open) */
.field-settings-panel {
  margin-top: 12px;
  padding: 10px 0 0 0;
  border-top: 1px solid var(--settings-border);
}

/* Character counter remains visible when settings panel is open */

.field-settings-panel.hidden {
  display: none;
}

/* ====================
   DETACHED PANEL CARD — replaces wrap-based pattern
   Input gets a coloured left-border accent; panel appears as its own card below
   ==================== */

/* Input accent when settings panel is open (excludes rich text editors) */
.sidebar-card__field.is-settings-open input.input-field,
.sidebar-card__field.is-settings-open textarea.input-field {
  border-left: 3px solid var(--settings-color);
  padding-left: 10px;
  transition: border-color 0.2s ease, padding-left 0.2s ease;
}

/* Input accent when AI panel is open (excludes rich text editors) */
.sidebar-card__field.is-ai-open input.input-field,
.sidebar-card__field.is-ai-open textarea.input-field {
  border-left: 3px solid var(--ai-color-light);
  padding-left: 10px;
  transition: border-color 0.2s ease, padding-left 0.2s ease;
}

/* Rich text editors excluded from accent — container is a div, not input/textarea.
   Explicit rule guards against regressions if selector patterns change. */
.sidebar-card__field.is-settings-open .rich-text-editor-container,
.sidebar-card__field.is-ai-open .rich-text-editor-container {
  border-left-width: 1px;
  padding-left: 0;
}

/* Detached panel card — settings variant */
.field-panel-card {
  margin-top: 6px;
  padding: var(--space-md);
  background: var(--settings-bg-inner);
  border: 1px solid var(--settings-border);
  border-left: 3px solid var(--settings-color);
  border-radius: var(--radius-md);
  animation: fieldPanelIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Spacing below panel card when inside grouped fields */
.sidebar-card__field--grouped .field-panel-card {
  margin-bottom: var(--space-sm);
}

/* Detached panel card — AI variant */
.field-panel-card--ai {
  background: var(--ai-bg);
  border-color: var(--ai-border);
  border-left-color: var(--ai-color-light);
}

/* Override default field-settings-panel styles when used as detached card */
.field-panel-card.field-settings-panel {
  margin-top: 6px;
  padding: var(--space-md);
}

@keyframes fieldPanelIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Legacy popover styles - deprecated, kept for backwards compat */
.field-settings-popover {
  display: none;
}

/* Compact row: Type + Limit side by side.
   Header row has titles, body row has controls in a single flex container
   so the select and input group share the same cross-axis alignment. */
.field-settings-compact-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-settings-compact-row__header {
  display: flex;
  gap: 10px;
}

.field-settings-compact-row__label--type {
  width: 90px;
  flex-shrink: 0;
}

.field-settings-compact-row__body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-settings-compact-row__body .field-type-select-wrapper {
  width: 90px;
  flex-shrink: 0;
}

/* Remove extra title margin inside compact row */
.field-settings-compact-row .field-settings-title {
  margin-bottom: 0;
}

/* Toggle + char input on same line */
.field-settings-compact-row .field-settings-row {
  gap: 6px;
  align-items: center;
}

/* No extra margin on char-limit wrapper in compact context */
.field-settings-compact-row .char-limit-input-wrapper {
  margin-top: 0;
}

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

.field-settings-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.field-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-settings-row .toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
  cursor: default;
  padding: 0;
  border-bottom: none;
}

.char-limit-input-wrapper {
  margin-top: 2px;
}

.char-limit-input-wrapper.hidden {
  display: none;
}

/* Input with suffix - scoped to panel to avoid global input style conflicts */
.field-settings-panel .char-limit-input-group {
  display: flex;
  align-items: center;
  height: 27px;
  background: var(--app-gray-50);
  border: 1px solid var(--app-gray-200);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-settings-panel .char-limit-input-group:focus-within {
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

/* Reset all inherited input styles within panel
   Uses #editor-content to override the ID-scoped input rules at line ~1481 */
#editor-content .field-settings-panel input[type="number"] {
  width: 40px;
  height: 100%;
  padding: 0 0 0 8px;
  font-size: 13px;
  line-height: 25px;
  font-weight: 500;
  color: var(--app-gray-700);
  background: transparent;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  -moz-appearance: textfield;
}

#editor-content .field-settings-panel input[type="number"]::-webkit-outer-spin-button,
#editor-content .field-settings-panel input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field-settings-panel .char-limit-suffix {
  padding: 0 8px 0 2px;
  font-size: 12px;
  line-height: 25px;
  color: var(--app-gray-400);
  white-space: nowrap;
}

/* ====================
   RICH TEXT SETTINGS PANEL
   ==================== */

/* Divider between sections */
.field-settings-divider {
  height: 1px;
  background: var(--settings-border);
  margin: 8px 0;
}

/* Field type select */
.field-type-select-wrapper {
  position: relative;
}

#editor-content .field-settings-panel .field-type-select {
  width: 100%;
  height: 27px;
  padding: 0 28px 0 8px;
  font-size: 13px;
  line-height: 25px;
  font-weight: 500;
  color: var(--app-gray-700);
  background: var(--app-gray-50);
  border: 1px solid var(--app-gray-200);
  border-radius: 6px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#editor-content .field-settings-panel .field-type-select:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.field-type-select-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--app-gray-400);
}

/* ====================
   Field Options (mm-presets style dropdowns within field cards)
   Part of the sidebar-card BEM block
   ==================== */

.sidebar-card__field-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

/* ====================
   Variant Sections (mm-variant)
   Variant selection UI with dynamic placeholder fields
   ==================== */

.variant-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 4px;
}

.variant-section-header {
  margin-bottom: 14px;
}

.variant-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #0369a1;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Variant dropdown row */
.variant-dropdown-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #bae6fd;
}

.variant-dropdown-label {
  font-size: 12px;
  font-weight: 600;
  color: #0c4a6e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.variant-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 200px;
}

.variant-select {
  width: 100%;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #0c4a6e;
  background: var(--app-white);
  border: 1px solid #7dd3fc;
  border-radius: 6px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.variant-select:hover {
  border-color: #38bdf8;
  background-color: #fefefe;
}

.variant-select:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.variant-select-icon {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: #0284c7;
  transition: color 0.15s ease;
}

.variant-select:hover+.variant-select-icon {
  color: #0369a1;
}

/* Variant fields container */
.variant-fields-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.variant-field-label {
  font-size: 11px;
  font-weight: 600;
  color: #0c4a6e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.variant-field-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 400;
  color: #1e293b;
  background: var(--app-white);
  border: 1px solid #7dd3fc;
  border-radius: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.variant-field-input:hover {
  border-color: #38bdf8;
}

.variant-field-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.variant-field-input::placeholder {
  color: var(--app-gray-400);
}

/* Variant field textarea */
textarea.variant-field-input {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

/* Variant character counter */
.variant-char-counter {
  display: block;
  font-size: 10px;
  color: var(--app-gray-500);
  text-align: right;
  margin-top: 2px;
}

.variant-char-counter.at-limit {
  color: var(--app-red-600);
  font-weight: 600;
}

/* Rich text settings container */
.rich-text-settings.hidden {
  display: none;
}

/* Rich controls grid */
.rich-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Clear Formatting spans full width as last odd item */
.rich-controls-grid .rich-control-checkbox:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* Checkbox styling for rich controls */
.rich-control-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
}

.rich-control-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--app-primary, #2563eb);
  flex-shrink: 0;
}

.rich-control-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
  user-select: none;
}

/* Error message for controls validation */
.rich-controls-error {
  font-size: 12px;
  color: var(--app-red-600);
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--app-red-50);
  border-radius: 4px;
  border: 1px solid var(--app-red-200);
}

.rich-controls-error.hidden {
  display: none;
}

/* Link styling section */
.link-styling-section.hidden,
.text-color-section.hidden {
  display: none;
}

.field-settings-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-gray-500);
  margin-bottom: 6px;
}

/* Color input group (picker + hex) */
.color-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--app-gray-50);
  border: 1px solid var(--app-gray-200);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 10px;
}

#editor-content .field-settings-panel .color-input-group input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

#editor-content .field-settings-panel .color-input-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

#editor-content .field-settings-panel .color-input-group input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

#editor-content .field-settings-panel input[type="text"].link-color-hex,
#editor-content .field-settings-panel input[type="text"].preset-hex-input {
  width: 80px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-weight: 500;
  color: var(--app-gray-700);
  background: transparent;
  border: none;
  border-radius: 0;
  text-transform: uppercase;
}

#editor-content .field-settings-panel input[type="text"].link-color-hex:focus-visible,
#editor-content .field-settings-panel input[type="text"].preset-hex-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.link-color-row {
  margin-bottom: 4px;
}

.link-options-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Color mode options (radio buttons) */
.color-mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.color-mode-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
}

.color-mode-radio input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--app-primary, #2563eb);
  flex-shrink: 0;
}

.color-mode-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
  user-select: none;
}

/* Color presets section */
.color-presets-section.hidden {
  display: none;
}

.color-presets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.color-preset-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--app-white);
  border: 1px solid var(--app-gray-200);
  border-radius: 6px;
  padding: 6px 8px;
}

#editor-content .field-settings-panel .color-preset-item input[type="color"] {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

#editor-content .field-settings-panel .color-preset-item input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

#editor-content .field-settings-panel .color-preset-item input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

#editor-content .field-settings-panel .preset-name-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-gray-700);
  background: transparent;
  border: none;
  border-radius: 0;
}

#editor-content .field-settings-panel .preset-name-input::placeholder {
  color: var(--app-gray-400);
}

#editor-content .field-settings-panel .preset-name-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

#editor-content .field-settings-panel .preset-hex-input {
  width: 70px;
  flex-shrink: 0;
}

.preset-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--app-gray-400);
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.preset-remove-btn:hover {
  color: var(--app-red-600);
  background: var(--app-red-50);
}

/* Add preset button */
.add-preset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-primary, #2563eb);
  background: #EFF6FF;
  border: 1px dashed #BFDBFE;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.add-preset-btn:hover {
  background: #DBEAFE;
  border-color: #93C5FD;
}

.add-preset-btn svg {
  flex-shrink: 0;
}

/* Panel layout adjustment for rich text settings */
.field-settings-panel:has(.rich-text-settings:not(.hidden)) {
  /* Panel is full width, no min-width needed for inline layout */
}

/* Small toggle switch variant */
.toggle-switch--sm {
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle-switch--sm .toggle-slider::before {
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
}

.toggle-switch--sm input[type="checkbox"]:checked+.toggle-slider::before {
  transform: translateX(14px);
}

/* ====================
   CHARACTER COUNTER
   ==================== */

.sidebar-card__char-counter {
  font-size: 11px;
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
}

.sidebar-card__char-counter--at-limit {
  color: var(--app-red);
}

/* Field label — consistent style for all field labels */
.sidebar-card__field-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.option-sets__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--card-border);
  margin-top: 6px;
  padding-top: 12px;
}

/* Section labels inside accent card body get consistent top border dividers */
.sidebar-card__body .option-sets__label {
  border-top: 1px solid var(--card-border);
  margin-top: 4px;
  padding-top: 12px;
}

.sidebar-card__field--grouped {
  background: var(--card-bg-white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

/* Variable controls container inside a field or card body */
.sidebar-card__field-variables {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Hint text below field inputs */
.sidebar-card__field-hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--app-gray-400);
}

/* ====================
   Options-only field styling
   Uses standard field structure, just hides the redundant top-level header
   ==================== */

/* Hide the top-level header for options-only fields (individual options have their own labels) */
.sidebar-card__field--paired.sidebar-card__field--options-only>.sidebar-card__field-header,
.sidebar-card__field--grouped.sidebar-card__field--options-only>.sidebar-card__field-header,
.sidebar-card--nested .sidebar-card__field--options-only>.sidebar-card__field-header {
  display: none;
}

/* Template Settings */
#template-settings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 20px;
}

/* ====================
   FREE TEMPLATE SETTINGS (ADMIN ONLY)
   ==================== */

.free-template-section {
  padding: 0 20px 12px;
}

.free-template-section .sidebar-title {
  padding: 12px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Admin Badge */
.admin-badge {
  background-color: var(--color-primary);
  color: var(--app-white);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 5px;
  border-radius: 2px;
  text-transform: uppercase;
}

/* Compact Toggle Container */
.free-template-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Toggle Row - Compact */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--editor-border);
}

.toggle-label {
  flex: 1;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: #333;
  line-height: 1.3;
}

/* Compact Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--app-gray-300-g);
  transition: background-color 0.2s ease;
  border-radius: 20px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: transform 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input[type="checkbox"]:checked+.toggle-slider {
  background-color: var(--color-primary);
}

.toggle-switch input[type="checkbox"]:checked+.toggle-slider::before {
  transform: translateX(16px);
}

.toggle-switch input[type="checkbox"]:focus-visible+.toggle-slider {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Wrapper toggle: hide dependent field containers */
.is-toggle-hidden {
  display: none;
}

/* Self-toggle: hide card body but keep card header (with toggle switch) visible */
.sidebar-card.is-toggle-hidden-content .sidebar-card__body {
  display: none;
}

/* Self-toggle inside repeater: hide input area but keep field header visible */
.sidebar-card__field.is-toggle-hidden-content > *:not(.sidebar-card__field-header) {
  display: none;
}

/* Free Template Fields - Progressive Disclosure */
.free-template-fields {
  opacity: 1;
  max-height: 1000px;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.3s ease;
}

.free-template-fields.hidden {
  opacity: 0;
  max-height: 0;
  pointer-events: none;
}

/* Auto-save Indicator */
.auto-save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #10B981;
  padding-top: 8px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.auto-save-indicator.hidden {
  opacity: 0;
  pointer-events: none;
}

.auto-save-indicator .save-icon {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  color: #10B981;
}

.auto-save-indicator.saving {
  color: var(--app-gray-500-g);
}

.auto-save-indicator.saving .save-icon {
  color: var(--app-gray-500-g);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Module Settings */
.module-settings {
  border-bottom: 1px solid var(--app-gray-200-g);
  padding-bottom: 16px;
}


/* ====================
   SECTION & INFO COMPONENTS
   ==================== */

.section-divider {
  border-top: 1px solid var(--card-border);
  margin-top: 4px;
  padding-top: 12px;
}

.section-divider h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

/* ====================
   UNIFIED SIDEBAR CARD
   Used by both Template and Campaign editors
   ==================== */

/* Base sidebar card */
.sidebar-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--card-padding);
}

/* Module card (non-nested) gets subtle shadow for prominence */
.sidebar-card:not(.sidebar-card--nested) {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Accent modifier for template editor - blue gradient top bar */
.sidebar-card--with-accent {
  position: relative;
  border-radius: var(--radius-lg);
  border-top: none;
}

.sidebar-card--with-accent::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-blue-light) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Accent card body — whitespace only separates header from body (card border + accent bar are sufficient) */
.sidebar-card--with-accent>.sidebar-card__body {
  margin-top: 14px;
  padding-top: 0;
}

/* Card footer — separated action zone for navigation buttons like Edit Code */
.sidebar-card__footer {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--card-border);
}

/* Remove redundant container margins when inside body */
.sidebar-card__body .sidebar-card__option-sets,
.sidebar-card__body #variants-preview-container {
  margin: 0;
}

/* Nested cards use flex layout for consistent title→body spacing */
.sidebar-card--nested {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

/* Top-level field groups (direct children of editor-content)
   Use gray background to contrast with sidebar background */
#editor-content>.sidebar-card--nested {
  background: var(--card-bg);
}

/* Sub-groups inside a card body - white for inset/layered effect */
.sidebar-card__body>.sidebar-card--nested {
  background: var(--card-bg-white);
}

/* Deep nesting (3+ levels) - subtle gray */
.sidebar-card__body .sidebar-card__body>.sidebar-card--nested {
  background: var(--card-bg-nested);
  border-color: var(--card-border-light);
}

/* Header row - flex container with title and actions */
.sidebar-card__header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--card-gap);
}

/* Left side info (label + title) */
.sidebar-card__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

/* Uppercase label (e.g., "EDITING MODULE") */
.sidebar-card__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin: 0;
}

/* Card title — one consistent style everywhere */
.sidebar-card__title {
  font-size: var(--text-title-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Self-toggle: title contains text + toggle switch side by side */
.sidebar-card__title:has(.toggle-switch) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Title row wrapper (used when settings button is present) */
.sidebar-card__title-row {
  display: flex;
  align-items: center;
}

.sidebar-card__title-row>.sidebar-card__title {
  flex: 1;
}

/* Action buttons container */
.sidebar-card__actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: -2px;
  flex-shrink: 0;
}

/* Body — flex column with consistent gap between fields */
.sidebar-card__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Collapsible group header */
.sidebar-card__group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}

/* Chevron icon */
.sidebar-card__group-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--app-gray-400);
  transition: transform 0.2s ease;
}

/* Collapse animation container (same grid-row pattern as repeater rows) */
.sidebar-card__group-collapse {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  transition: grid-template-rows 0.25s ease;
}

/* Collapsed state: rotate chevron */
.sidebar-card--collapsible.is-collapsed .sidebar-card__group-chevron {
  transform: rotate(-90deg);
}

/* Collapsed state: hide content */
.sidebar-card--collapsible.is-collapsed .sidebar-card__group-collapse {
  grid-template-rows: 0fr;
}

/* Inner body needs min-height: 0 for grid collapse */
.sidebar-card__group-collapse > .sidebar-card__body {
  min-height: 0;
  overflow: hidden;
}

/* Option row within sidebar card body */
.sidebar-card__option-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-card__option-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-label);
}

.sidebar-card__option-select {
  width: 100%;
  padding: var(--form-padding-y) 32px var(--form-padding-y) var(--form-padding-x);
  font-size: var(--form-font-size);
  color: var(--text-primary);
  background-color: var(--card-bg-white);
  border: var(--form-border-width) solid var(--card-border);
  border-radius: var(--form-border-radius);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--form-padding-x) center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.sidebar-card__option-select:hover {
  border-color: var(--app-gray-300);
}

.sidebar-card__option-select:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

/* Template editor specific: name input and edit code button */
.sidebar-card__name-input {
  width: 100%;
  border: 1px solid var(--app-gray-300-g);
  background: var(--card-bg-white);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 10px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.sidebar-card__name-input:hover {
  border-color: var(--app-gray-400-g);
}

.sidebar-card__name-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

/* Action buttons within sidebar card header */
.sidebar-card__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--card-border);
  background: var(--card-bg-white);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-card__action-btn:hover {
  border-color: var(--app-gray-300);
  background: var(--card-bg);
}

.sidebar-card__action-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.sidebar-card__action-btn img {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.sidebar-card__action-btn:hover img {
  opacity: 0.8;
}

/* Danger variant for delete button */
.sidebar-card__action-btn--danger:hover {
  border-color: #FCA5A5;
  background: var(--app-red-50);
}

.sidebar-card__action-btn--danger:hover img {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(46%) sepia(84%) saturate(2618%) hue-rotate(339deg) brightness(95%) contrast(92%);
}

/* ====================
   REPEATER SECTIONS (mm-repeat)
   Part of sidebar-card BEM block
   ==================== */

/* Repeater card — groups repeatable field rows with add/remove controls */
.sidebar-card--repeater .sidebar-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.repeater__counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Individual repeater row container */
.repeater-row {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
}

/* Repeater row header — tinted clickable bar */
.repeater-row__header {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.repeater-row__header:hover {
  background: rgba(0, 0, 0, 0.055);
}

/* Chevron indicator */
.repeater-row__chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--app-gray-400);
  transition: transform 0.2s ease;
}

/* Row label — matches option-sets__label pattern (section divider label) */
.repeater-row__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Content summary shown when collapsed */
.repeater-row__summary {
  font-size: 11px;
  color: var(--app-gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  display: none;
}

/* Collapse wrapper — grid row transition for smooth actual-height animation */
.repeater-row__collapse {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  margin: 12px 0 6px;
  transition: grid-template-rows 0.25s ease, margin 0.25s ease;
}

/* Body wrapper for fields — inner content that shrinks via grid */
.repeater-row__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

/* Collapsed state */
.repeater-row.is-collapsed .repeater-row__chevron {
  transform: rotate(-90deg);
}

.repeater-row.is-collapsed .repeater-row__summary {
  display: block;
}

.repeater-row.is-collapsed .repeater-row__collapse {
  grid-template-rows: 0fr;
  margin: 0;
}

/* Drag handle — matches choice-row__drag-handle pattern */
.repeater-row__drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--app-gray-400);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.repeater-row__drag-handle:hover {
  color: var(--app-gray-600);
}

.repeater-row__drag-handle:active {
  cursor: grabbing;
}

/* Drag-and-drop states — matches choice-row ghost/drag pattern */
.repeater-row--dragging {
  opacity: 0.9;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.repeater-row--ghost {
  opacity: 0.4;
  border-style: dashed;
  border-color: var(--app-primary);
}

/* Row action buttons wrapper (clone + remove) */
.repeater-row__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

/* Clone row button — icon-only, blue hover */
.repeater-row__clone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--app-gray-400);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.repeater-row__clone:hover {
  color: var(--app-primary);
  background: var(--app-primary-light, rgba(59, 130, 246, 0.08));
}

.repeater-row__clone:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.repeater-row__clone svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Remove row button — icon-only, matches sidebar-card__action-btn pattern */
.repeater-row__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--app-gray-400);
  transition: color 0.15s ease, background 0.15s ease;
}

.repeater-row__remove:hover {
  color: var(--app-red);
  background: var(--app-red-50);
}

.repeater-row__remove svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Add row link at bottom of repeater — matches option-sets__add-link pattern */
.repeater__add-btn {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-primary);
  background: none;
  border: none;
  padding: 4px 0;
  margin-top: 12px;
  cursor: pointer;
  text-decoration: none;
}

.repeater__add-btn:hover {
  text-decoration: underline;
}

.repeater__add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .sidebar-card--with-accent {
    padding: 16px;
  }

  .sidebar-card__header {
    flex-direction: column;
    gap: var(--card-gap);
    align-items: stretch;
  }

  .sidebar-card__actions {
    justify-content: flex-end;
  }
}

/* ====================
   RESPONSIVE DESIGN
   ==================== */

@media (max-width: 600px) {
  .dropdown {
    left: 20px;
    right: 20px;
    width: auto;
  }

  /* Modal responsive styles are in /css/components/modal.css */

  .sidebar-card--nested {
    padding: 12px;
  }
}

/* ====================
   ACTION BUTTONS
   Text buttons used for actions like "Edit Code"
   ==================== */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px solid var(--card-border);
  background: var(--card-bg-white);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  color: #4B5563;
  padding: 0 12px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.action-btn:hover {
  border-color: var(--app-gray-300);
  background: var(--card-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.action-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ====================
   EXPORT HTML MODAL
   ==================== */

.export-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.export-loading p {
  color: var(--app-gray-500-g);
  margin: 0;
}

.export-content {
  max-height: 400px;
  overflow: hidden;
}

.export-code-container {
  max-height: 400px;
  overflow: auto;
  background: #1e1e1e;
  border-radius: 6px;
  margin: 0;
}

.export-code-container pre {
  margin: 0;
  padding: 16px;
}

.export-code-container code {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-all;
}

.export-error {
  padding: 40px 20px;
  text-align: center;
}

.export-error p {
  color: var(--app-red-600);
  margin: 0;
}

/* Footer buttons with icons */
#export-modal .modal__footer {
  display: flex;
  gap: 12px;
}

#export-modal .modal__footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#export-modal .modal__footer .btn svg {
  flex-shrink: 0;
}

#export-modal .modal__footer .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ====================
   HEADER MENU DROPDOWN
   ==================== */

.header-menu-wrapper {
  position: relative;
}

.header-menu-dropdown {
  background: var(--app-white);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
  min-width: 200px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 1000;
}

.header-menu-dropdown.hidden {
  display: none;
}

.header-menu-dropdown .header-menu-item {
  align-items: center;
  border-radius: 6px;
  color: var(--app-gray-700-g);
  display: flex;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.header-menu-dropdown .header-menu-item:hover {
  background-color: var(--app-gray-100-g);
}

.header-menu-dropdown .header-menu-item svg {
  color: var(--app-gray-500-g);
  flex-shrink: 0;
}

.header-menu-dropdown .header-menu-item--danger {
  color: var(--app-red-600);
}

.header-menu-dropdown .header-menu-item--danger svg {
  color: var(--app-red-600);
}

.header-menu-dropdown .header-menu-item--danger:hover {
  background-color: var(--app-red-50);
}

.header-menu-dropdown .header-menu-divider {
  background-color: var(--app-gray-200-g);
  height: 1px;
  margin: 6px 0;
}

/* ====================
   SLIDE PANEL COMPONENT
   Reusable slide-over panel for sidebars and overlays
   ==================== */

:root {
  --slide-panel-width: 440px;
  --slide-panel-header-height: 57px;
}

/* Overlay backdrop */
.slide-panel-overlay {
  background-color: rgba(0, 0, 0, 0.3);
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1100;
}

.slide-panel-overlay.hidden {
  display: none;
}

/* Panel container - slides in from right */
.slide-panel {
  background: var(--app-white);
  box-shadow: var(--shadow-2xl, -4px 0 25px rgba(0, 0, 0, 0.15));
  display: flex;
  flex-direction: column;
  height: 100%;
  width: var(--slide-panel-width);
}

/* Panel header - fixed at top */
.slide-panel__header {
  align-items: center;
  background: var(--app-white);
  border-bottom: 1px solid var(--app-gray-200-g);
  box-sizing: border-box;
  display: flex;
  flex-shrink: 0;
  height: var(--slide-panel-header-height);
  justify-content: space-between;
  padding: 0 var(--space-xl, 20px);
}

.slide-panel__title {
  color: var(--app-gray-900-g);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.slide-panel__title.hidden {
  display: none;
}

/* Back button in header */
.slide-panel__back {
  align-items: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm, 6px);
  color: var(--app-gray-700-g);
  cursor: pointer;
  display: flex;
  font-size: 1rem;
  font-weight: 600;
  gap: var(--space-sm, 8px);
  margin: calc(-1 * var(--space-sm, 8px)) calc(-1 * var(--space-md, 12px));
  padding: var(--space-sm, 8px) var(--space-md, 12px);
  transition: background-color 0.15s ease;
}

.slide-panel__back:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.slide-panel__back.hidden {
  display: none;
}

.slide-panel__back svg {
  flex-shrink: 0;
}

/* Close button */
.slide-panel__close {
  align-items: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm, 6px);
  color: var(--app-gray-500-g);
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: var(--space-sm, 8px);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.slide-panel__close:hover {
  background-color: var(--app-gray-100-g);
  color: var(--app-gray-700-g);
}

/* Panel body - scrollable content area */
.slide-panel__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  /* Allow flexbox to shrink below content size */
  overflow-y: auto;
}

/* Panel sections - switchable content areas that fill the body */
.slide-panel__section {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  /* Allow flexbox children to shrink */
}

.slide-panel__section.hidden {
  display: none;
}

/* Panel footer - fixed at bottom */
.slide-panel__footer {
  border-top: 1px solid var(--app-gray-200-g);
  flex-shrink: 0;
  padding: var(--space-lg, 16px);
}

.slide-panel__footer.hidden {
  display: none;
}

.slide-panel__footer .btn {
  width: 100%;
}

/* Loading state */
.slide-panel__loading {
  align-items: center;
  color: var(--app-gray-500-g);
  display: flex;
  flex-direction: column;
  gap: var(--space-md, 12px);
  justify-content: center;
  padding: 60px var(--space-xl, 20px);
}

.slide-panel__loading.hidden {
  display: none;
}

/* Empty state */
.slide-panel__empty {
  align-items: center;
  color: var(--app-gray-500-g);
  display: flex;
  flex-direction: column;
  gap: var(--space-md, 12px);
  padding: 60px var(--space-xl, 20px);
  text-align: center;
}

.slide-panel__empty.hidden {
  display: none;
}

.slide-panel__empty svg {
  color: var(--app-gray-300-g);
}

.slide-panel__empty p {
  color: var(--app-gray-700-g);
  font-weight: 500;
  margin: 0;
}

.slide-panel__empty span {
  font-size: 0.875rem;
}

/* Inline confirmation block */
.slide-panel__confirmation {
  background: #FFFBEB;
  border-top: 1px solid #FDE68A;
  flex-shrink: 0;
  padding: var(--space-lg, 16px);
}

.slide-panel__confirmation.hidden {
  display: none;
}

.slide-panel__confirmation-content {
  margin-bottom: var(--space-md, 12px);
}

.slide-panel__confirmation-content p {
  color: #92400E;
  font-size: 0.875rem;
  margin: 0 0 4px 0;
}

.slide-panel__confirmation-content .help-text {
  color: #B45309;
  font-size: 0.8125rem;
  margin: 0;
}

.slide-panel__confirmation-actions {
  display: flex;
  gap: var(--space-sm, 8px);
}

.slide-panel__confirmation-actions .btn {
  flex: 1;
}

/* ====================
   VERSION HISTORY PANEL
   Extends slide panel component
   ==================== */

/* Version list */
.version-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-md, 12px) var(--space-sm, 8px);
}

.version-history-list.hidden {
  display: none;
}

/* Base version item - horizontal layout with icon */
.version-item {
  align-items: flex-start;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  display: flex;
  gap: var(--space-sm, 10px);
  padding: var(--space-md, 12px) var(--space-sm, 12px);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.version-item:hover {
  background-color: var(--app-gray-50-g);
  border-color: var(--app-gray-200-g);
}

/* Version type icon container */
.version-item-icon {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.version-item-icon .version-type-icon {
  color: var(--app-gray-400-g);
  height: 16px;
  width: 16px;
}

/* Version content area */
.version-item-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.version-item-header {
  align-items: baseline;
  display: flex;
  gap: var(--space-sm, 8px);
  justify-content: space-between;
}

.version-title {
  color: var(--app-gray-700-g);
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-date {
  color: var(--app-gray-400-g);
  flex-shrink: 0;
  font-size: 0.75rem;
}

.version-item-meta {
  color: var(--app-gray-400-g);
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  gap: 2px;
}

.version-author {
  color: var(--app-gray-400-g);
}

.version-notes {
  color: var(--app-gray-500-g);
  font-size: 0.8125rem;
  line-height: 1.4;
  margin-top: 2px;
}

/* ===== Autosave versions - subtle, secondary appearance ===== */
.version-item--autosave {
  background-color: transparent;
}

.version-item--autosave:hover {
  background-color: var(--app-gray-50-g);
  border-color: var(--app-gray-200-g);
}

.version-item--autosave .version-title {
  color: var(--app-gray-500-g);
  font-weight: 400;
}

.version-item--autosave .version-item-icon .version-type-icon {
  color: var(--app-gray-300-g);
}

/* ===== Named versions - prominent, primary appearance ===== */
.version-item--named {
  background-color: #FAFBFF;
  border-color: #E0E7FF;
}

.version-item--named:hover {
  background-color: #F0F4FF;
  border-color: #C7D2FE;
}

.version-item--named .version-title {
  color: #1E293B;
  font-weight: 600;
}

.version-item--named .version-item-icon .version-type-icon {
  color: var(--app-primary, #2563eb);
}

.version-item--named .version-date {
  color: var(--app-gray-500-g);
}

/* Legacy support - remove old badge-based styling */
.version-number {
  color: var(--app-gray-900-g);
  font-size: 0.875rem;
  font-weight: 600;
}

.named-badge {
  display: none;
  /* Deprecated - type now indicated by icon */
}

/* Version filter toggle */
.version-filter {
  background-color: #FAFAFA;
  border-bottom: 1px solid var(--app-gray-200-g);
  padding: var(--space-sm, 10px) var(--space-lg, 16px);
}

.version-filter.hidden {
  display: none;
}

.filter-toggle {
  align-items: center;
  color: var(--app-gray-500-g);
  cursor: pointer;
  display: flex;
  font-size: 0.8125rem;
  gap: 8px;
  user-select: none;
}

.filter-toggle:hover {
  color: var(--app-gray-700-g);
}

.filter-toggle input[type="checkbox"] {
  accent-color: var(--app-primary, #2563eb);
  cursor: pointer;
  height: 14px;
  width: 14px;
}

/* No versions message */
.no-versions {
  color: var(--app-gray-500-g);
  font-size: 0.875rem;
  padding: var(--space-xl, 24px) var(--space-lg, 16px);
  text-align: center;
}

/* Version preview */
.version-preview-details {
  align-items: center;
  border-bottom: 1px solid var(--app-gray-200-g);
  display: flex;
  flex-shrink: 0;
  gap: var(--space-md, 12px);
  justify-content: space-between;
  padding: var(--space-md, 12px) var(--space-lg, 16px);
}

.version-preview-label {
  color: var(--app-gray-900-g);
  font-size: 0.875rem;
  font-weight: 600;
}

.version-preview-date {
  color: var(--app-gray-500-g);
  font-size: 0.8125rem;
}

.version-preview-frame {
  background: var(--app-gray-100-g);
  flex: 1;
  min-height: 200px;
  /* Minimum height for usability */
  overflow: hidden;
  padding: var(--space-lg, 16px);
  position: relative;
}

.version-preview-frame iframe {
  background: var(--app-white);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 4px;
  height: calc((100% - 32px) / 0.6);
  /* Compensate for scale and padding */
  left: 16px;
  position: absolute;
  top: 16px;
  transform: scale(0.6);
  transform-origin: top left;
  width: calc((100% - 32px) / 0.6);
  /* Compensate for scale and padding */
}

/* Save Version Modal styles moved to /css/components/modal.css */

/* ====================
   RICH TEXT EDITOR COMPONENT
   ==================== */

.rich-text-editor-container {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--app-gray-300-g);
  border-radius: 6px;
  background: var(--app-white);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rich-text-editor-container:focus-within {
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

/* Toolbar */
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--app-gray-50-g);
  border-bottom: 1px solid var(--app-gray-200-g);
  flex-wrap: wrap;
}

.rte-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--app-gray-500-g);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.rte-btn:hover {
  background: var(--app-gray-200-g);
  color: var(--app-gray-700-g);
}

.rte-btn.active {
  background: #E0E7FF;
  color: #4F46E5;
}

.rte-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rte-separator {
  width: 1px;
  height: 20px;
  background: var(--app-gray-200-g);
  margin: 0 4px;
}

/* Color button - icon stroke changes to match selected color */
.rte-color-icon {
  transition: stroke 0.15s ease;
}

/* Editor wrapper */
.rte-editor-wrapper {
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
}

.rte-editor-wrapper.focused {
  /* Additional focus styles if needed */
}

.rte-editor {
  padding: 12px;
}

/* Tiptap/ProseMirror content styles */
.rte-prosemirror {
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--app-gray-700-g);
}

.rte-prosemirror p {
  margin: 0 0 0.75em 0;
}

.rte-prosemirror p:last-child {
  margin-bottom: 0;
}

.rte-prosemirror a {
  color: var(--app-blue-400);
  text-decoration: underline;
}

.rte-prosemirror strong {
  font-weight: 600;
}

.rte-prosemirror em {
  font-style: italic;
}

.rte-prosemirror u {
  text-decoration: underline;
}

.rte-prosemirror s {
  text-decoration: line-through;
}

/* Placeholder */
.rte-prosemirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--app-gray-400-g);
  float: left;
  height: 0;
  pointer-events: none;
}

/* Character counter */
.rte-char-counter {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--app-gray-500-g);
  text-align: right;
  background: var(--app-gray-50-g);
  border-top: 1px solid var(--app-gray-200-g);
}

.rte-char-counter.at-limit {
  color: var(--app-red-600);
  font-weight: 500;
}

/* Link Popover */
.rte-link-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--app-white);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 14px;
  animation: rtePopoverIn 0.15s ease-out;
}

@keyframes rtePopoverIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

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

.rte-popover-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rte-popover-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-gray-400-g);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.rte-link-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--app-gray-200-g);
  border-radius: 6px;
  background: var(--app-gray-50-g);
  color: var(--app-gray-700-g);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rte-link-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.rte-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.rte-popover-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.rte-popover-btn--primary {
  background: #4F46E5;
  color: var(--app-white);
}

.rte-popover-btn--primary:hover {
  background: #4338CA;
}

.rte-popover-btn--secondary {
  background: var(--app-gray-100-g);
  color: var(--app-gray-700-g);
}

.rte-popover-btn--secondary:hover {
  background: var(--app-gray-200-g);
}

.rte-popover-btn--danger {
  background: #FEE2E2;
  color: var(--app-red-600);
}

.rte-popover-btn--danger:hover {
  background: var(--app-red-200);
}

/* Color Popover */
.rte-color-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--app-white);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 14px;
  animation: rtePopoverIn 0.15s ease-out;
}

.rte-color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.rte-color-swatch {
  width: 28px;
  height: 28px;
  border: 2px solid #FFFFFF;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rte-color-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

.rte-color-custom {
  padding-top: 10px;
  border-top: 1px solid var(--app-gray-200-g);
}

.rte-color-presets+.rte-color-custom {
  margin-top: 4px;
}

.rte-color-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rte-color-picker {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--app-gray-200-g);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.rte-color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.rte-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.rte-color-hex {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-weight: 500;
  color: var(--app-gray-700-g);
  background: var(--app-gray-50-g);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 4px;
  text-transform: uppercase;
}

.rte-color-hex:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.rte-color-apply {
  flex-shrink: 0;
}

/* ====================
   OPTION SETS MANAGER (Template Editor)
   UI for creating/editing mm-presets definitions
   Uses BEM naming convention
   ==================== */

/* Option Sets Panel Block */
.option-sets {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.option-sets__add-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-primary);
  text-decoration: none;
  padding: 4px 0;
  cursor: pointer;
}

.option-sets__add-link:hover {
  text-decoration: underline;
}

/* Option Sets List */
.option-sets__list {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.option-sets__list:empty {
  display: none;
}

/* Option Set Item — uses sidebar-card__option-row for structure */
.option-set__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

/* Subtle dot to indicate option is applied */
.option-set__applied-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--app-green);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}

.option-set__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Global scope indicator (globe icon) */
.option-set__scope-icon {
  display: inline-flex;
  align-items: center;
  color: var(--app-gray-400);
  vertical-align: middle;
  margin-left: 4px;
}

/* Spacing before Edit Code button when option-sets panel is present */
.sidebar-card__option-sets+.action-btn {
  margin-top: 4px;
}

/* ====================
   OPTION SET MODAL FORM
   ==================== */

.option-set-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.option-set-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.option-set-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.option-set-form__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
}

.option-set-form__required {
  color: var(--app-red);
}

.option-set-form__help {
  font-size: 11px;
  color: var(--app-gray-400);
  margin-top: 2px;
}

.option-set-form__input {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--app-gray-300);
  border-radius: var(--radius-sm);
  background: var(--app-white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.option-set-form__input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.option-set-form__input:read-only {
  background: var(--app-gray-50);
  color: var(--app-gray-500);
}

/* Choices List */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.choice-row {
  background: var(--app-gray-50, var(--app-gray-50-g));
  border: 1px solid var(--app-gray-200, var(--app-gray-200));
  border-radius: var(--radius-sm);
  padding: var(--space-md, 12px);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 8px);
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.choice-row--dragging {
  opacity: 0.9;
  box-shadow: var(--shadow-lg, 0 4px 12px rgba(0, 0, 0, 0.15));
  z-index: 10;
}

.choice-row--ghost {
  opacity: 0.4;
  border-style: dashed;
  border-color: var(--app-primary, #2563eb);
}

.choice-row__drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--app-gray-400, var(--app-gray-400));
  padding: 4px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.choice-row__drag-handle:hover {
  color: var(--app-gray-600, var(--app-gray-600));
}

.choice-row__drag-handle:active {
  cursor: grabbing;
}

.choice-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-md, 12px);
}

.choice-row__default {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.choice-row__default input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--app-primary, #2563eb);
  cursor: pointer;
}

.choice-row__name {
  flex: 1;
  min-width: 100px;
}

.choice-row__styles {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  color: var(--app-gray-600, var(--app-gray-600));
  resize: none;
  overflow: hidden;
  max-height: 200px;
  line-height: 1.5;
  margin-left: 54px;
  width: calc(100% - 54px);
}

.choice-row__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--app-gray-400, var(--app-gray-400));
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.choice-row__remove:hover {
  background: var(--app-red-50, var(--app-red-50));
  color: var(--app-red, #ef4444);
}

/* Form Label Row with Help Tooltip */
.form-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-label-row label {
  margin: 0;
}

/* Tooltip trigger button */
.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--app-gray-300-g);
  border-radius: 50%;
  color: var(--app-gray-400-g);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.tooltip-trigger:hover {
  border-color: var(--app-blue-link);
  color: var(--app-blue-link);
  background: rgba(27, 105, 222, 0.05);
}

/* Small variant for tight spaces (14px) */
.tooltip-trigger--sm {
  width: 14px;
  height: 14px;
  font-size: 9px;
}

/* Tooltip container - Using fixed positioning to escape overflow containers */
.tooltip {
  position: fixed;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.tooltip--visible {
  opacity: 1;
  visibility: visible;
}

/* Tooltip content box */
.tooltip__content {
  position: relative;
  background: var(--app-gray-800-g);
  color: var(--app-gray-50-g);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 6px;
  min-width: 220px;
  max-width: 280px;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Tooltip arrow (pseudo-element on content) */
/* Arrow pointing down (tooltip above trigger) */
.tooltip--top .tooltip__content::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--app-gray-800-g);
}

/* Arrow pointing up (tooltip below trigger) */
.tooltip--bottom .tooltip__content::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--app-gray-800-g);
}

/* Arrow alignment variants */
.tooltip--align-left .tooltip__content::before {
  left: 16px;
  transform: none;
}

.tooltip--align-right .tooltip__content::before {
  left: auto;
  right: 16px;
  transform: none;
}

/* Form Field Description (always visible) */
.form-field-desc {
  font-size: 11px;
  color: var(--app-gray-400-g);
  margin: 2px 0 0;
  line-height: 1.4;
}

/* Section Description (for choices section) */
.form-section-desc {
  font-size: 12px;
  color: var(--app-gray-500-g);
  margin: 0 0 12px;
  line-height: 1.5;
}

/* Add Choice Button refinement */
.add-choice-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--app-gray-100-g);
  border: 1px dashed var(--app-gray-300-g);
  border-radius: 6px;
  color: var(--app-gray-500-g);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-choice-btn:hover {
  background: var(--app-gray-200-g);
  border-color: var(--app-gray-400-g);
  color: var(--app-gray-700-g);
}

.add-choice-btn svg {
  width: 14px;
  height: 14px;
}

/* ====================
   FIELD STYLE OPTIONS ASSIGNMENT
   Checkboxes in field settings panel
   ==================== */

.field-style-options-section {
  /* Section appears below other field settings */
}

.field-style-options-section.hidden {
  display: none;
}

.field-settings-hint {
  font-size: 12px;
  color: var(--app-gray-400);
  margin: 0 0 12px;
  line-height: 1.4;
}

.style-options-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-option-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
}

.style-option-checkbox:hover .style-option-label {
  color: var(--app-primary);
}

.style-option-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--app-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.style-option-checkbox input[type="checkbox"]:checked+.style-option-info .style-option-label {
  color: var(--app-primary);
}

.style-option-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.style-option-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--app-gray-700);
}

.style-option-meta {
  font-size: 11px;
  color: var(--app-gray-400);
}

/* Tooltip icon next to section title */
.field-settings-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-settings-hint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--app-gray-400);
  cursor: help;
}

/* Visual connector: blue left-border on option dropdowns when settings panel is open */
.sidebar-card__field.is-settings-open .sidebar-card__field-options .sidebar-card__field {
  border-left: 2px solid var(--settings-border);
  padding-left: 8px;
}

/* Done button footer inside field settings panel */
.field-settings-panel__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--settings-border);
}

.field-settings-done-btn {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-primary);
  background: transparent;
  border: 1px solid var(--app-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.field-settings-done-btn:hover {
  background: var(--app-primary);
  color: white;
}

/* ====================
   VARIANTS PREVIEW PANEL (Template Editor)
   Shows variant templates for preview/testing
   Uses BEM naming convention
   ==================== */

/* Variants Preview Panel Block */
.variants-preview {
  margin: 8px 0;
  border: 1px solid var(--app-gray-200-g);
  border-radius: 8px;
  background: #FAFAFA;
  overflow: hidden;
}

.variants-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: default;
  user-select: none;
}

.variants-preview__header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
}

.variants-preview__chevron {
  color: var(--app-gray-500-g);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.variants-preview__chevron--expanded {
  transform: rotate(90deg);
}

.variants-preview__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--app-gray-700-g);
}

.variants-preview__count {
  font-size: 11px;
  font-weight: 500;
  color: var(--app-gray-500-g);
  background: var(--app-gray-200-g);
  padding: 2px 6px;
  border-radius: 10px;
}

.variants-preview__content {
  border-top: 1px solid var(--app-gray-200-g);
  background: var(--app-white);
}

.variants-preview__content--hidden {
  display: none;
}

.variants-preview__empty {
  padding: 16px;
  text-align: center;
}

.variants-preview__empty p {
  margin: 0;
  font-size: 13px;
  color: var(--app-gray-500-g);
}

.variants-preview__empty-hint {
  font-size: 12px !important;
  color: var(--app-gray-400-g) !important;
  margin-top: 4px !important;
}

.variants-preview__list {
  display: flex;
  flex-direction: column;
}

/* Variant Preview Item Block */
.variant-preview {
  padding: 14px;
  border-bottom: 1px solid var(--app-gray-200-g);
}

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

.variant-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.variant-preview__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--app-gray-900-g);
}

.variant-preview__meta {
  font-size: 11px;
  color: var(--app-gray-400-g);
}

.variant-preview__controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.variant-preview__select-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.variant-preview__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--app-gray-500-g);
  min-width: 40px;
}

.variant-preview__select-wrapper {
  position: relative;
  flex: 1;
}

.variant-preview__select {
  width: 100%;
  padding: var(--form-padding-y) 32px var(--form-padding-y) var(--form-padding-x);
  font-size: var(--form-font-size);
  border: var(--form-border-width) solid var(--form-border-color);
  border-radius: var(--form-border-radius);
  background: var(--form-bg);
  cursor: pointer;
  appearance: none;
  color: var(--form-color);
  transition: border-color 0.15s ease;
}

.variant-preview__select:hover {
  border-color: var(--app-gray-400-g);
}

.variant-preview__select:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.variant-preview__select-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--app-gray-500-g);
}

.variant-preview__fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--app-gray-50-g);
  border-radius: 6px;
}

.variant-preview__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.variant-preview__field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--app-gray-500-g);
}

.variant-preview__field-input {
  padding: var(--form-padding-y) var(--form-padding-x);
  font-size: var(--form-font-size);
  border: var(--form-border-width) solid var(--form-border-color);
  border-radius: var(--form-border-radius);
  background: var(--form-bg);
  color: var(--form-color);
  transition: border-color 0.15s ease;
}

.variant-preview__field-input:hover {
  border-color: var(--app-gray-400-g);
}

.variant-preview__field-input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.variant-preview__field-input::placeholder {
  color: var(--form-placeholder-color);
}

.variant-preview__output {
  margin-top: 4px;
}

.variant-preview__output-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--app-gray-500-g);
  margin-bottom: 8px;
}

.variant-preview__output-html {
  padding: 12px;
  background: var(--app-gray-50-g);
  border: 1px solid var(--app-gray-200-g);
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.variant-preview__output-html .preview-placeholder {
  color: var(--app-gray-400-g);
  font-style: italic;
}

/* ====================
   OPTION SETS & VARIANTS INSIDE SIDEBAR CARD
   Compact styling when panels are embedded in sidebar-card--with-accent
   Uses BEM naming convention
   ==================== */

/* Container styling inside sidebar card - gap handled by body wrapper */
.sidebar-card--with-accent .sidebar-card__option-sets,
.sidebar-card--with-accent #variants-preview-container {
  margin: 0;
}

/* Hide empty containers */
.sidebar-card--with-accent .sidebar-card__option-sets:empty,
.sidebar-card--with-accent #variants-preview-container:empty {
  display: none;
}

/* Panel styling - compact, borderless inside accent card */
.sidebar-card--with-accent .option-sets {
  margin: 0;
  background: transparent;
  border: none;
}

/* =============================================
   Variables Panel
   ============================================= */

.variables-panel {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.variables-panel:empty {
  display: none;
}

.variables-panel__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--card-border);
  margin-top: 6px;
  padding-top: 12px;
}

.sidebar-card__body .variables-panel__label {
  border-top: 1px solid var(--card-border);
  margin-top: 4px;
  padding-top: 12px;
}

.variables-panel__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.variables-panel__list:empty {
  display: none;
}

.variable-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.variable-row__name,
.variable-row__value {
  flex: 1;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card-bg-white, #fff);
  color: var(--text-primary);
  font-family: inherit;
}

.variable-row__name {
  flex: 0 0 35%;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
}

.variable-row__value {
  flex: 1;
}

.variable-row__name:focus-visible,
.variable-row__value:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--focus-ring-color);
  box-shadow: var(--focus-ring-shadow);
}

.variable-row__remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0;
  line-height: 1;
}

.variable-row__remove:hover {
  background: var(--app-red-50, var(--app-red-50));
  color: var(--app-red, #ef4444);
}

.variables-panel__add-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-primary);
  text-decoration: none;
  padding: 4px 0;
  cursor: pointer;
}

.variables-panel__add-link:hover {
  text-decoration: underline;
}

/* Compact variant inside accent card */
.sidebar-card--with-accent .variables-panel {
  margin: 0;
  background: transparent;
  border: none;
}

/* Empty container hides itself */
#variables-container:empty,
#module-variables-container:empty {
  display: none;
}

.sidebar-card--with-accent .variants-preview {
  margin: 0;
  background: var(--app-gray-50);
  border: 1px solid var(--app-gray-200);
  border-radius: var(--radius-sm);
}

/* Action buttons inside option-sets panel use smaller sizing */
.option-set__actions .sidebar-card__action-btn {
  width: 28px;
  height: 28px;
}

.option-set__actions .sidebar-card__action-btn img {
  width: 14px;
  height: 14px;
}

/* Variants preview compact styling */
.sidebar-card--with-accent .variants-preview__content {
  padding: 0;
}

.sidebar-card--with-accent .variant-preview {
  padding: 12px;
}

.sidebar-card--with-accent .variants-preview__empty {
  padding: 14px 12px;
}

.sidebar-card--with-accent .variants-preview__empty p {
  font-size: 12px;
}

/* Empty fields message in sidebars */
.empty-fields-message {
  color: var(--app-gray-500);
  font-size: 13px;
}

.empty-fields-message--error {
  color: var(--app-red-600, var(--app-red-600));
  padding: 20px;
}

/* ====================
   AI GENERATE BUTTON — Ghost icon, fills on hover
   ==================== */

.ai-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #d4a574;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.3s ease, filter 0.3s ease;
}

.ai-generate-btn:hover {
  color: var(--ai-color-light);
  filter: drop-shadow(0 0 6px var(--ai-glow-strong)) drop-shadow(0 0 2px var(--ai-glow));
}

.ai-generate-btn:active {
  transform: scale(0.9);
}

.ai-generate-btn:hover .ai-generate-btn__icon {
  transform: scale(1.15) rotate(-8deg);
}

.ai-generate-btn__icon {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.3s ease;
}

.ai-generate-btn__icon path {
  fill: transparent;
  stroke: currentColor;
  transition: fill 0.3s ease, stroke 0.3s ease;
}

.ai-generate-btn:hover .ai-generate-btn__icon path {
  fill: var(--ai-color-light);
  stroke: var(--ai-color);
}

/* Persistent active state (when AI panel is open) */
.ai-generate-btn.is-active {
  color: var(--ai-color-light);
  filter: drop-shadow(0 0 6px var(--ai-glow-strong)) drop-shadow(0 0 2px var(--ai-glow));
}

.ai-generate-btn.is-active .ai-generate-btn__icon path {
  fill: var(--ai-color-light);
  stroke: var(--ai-color);
}

.ai-generate-btn__text {
  display: none;
}

.ai-generate-btn--loading {
  color: var(--ai-color-light);
  pointer-events: none;
  opacity: 0.7;
}

.ai-generate-btn--loading .ai-generate-btn__icon {
  animation: ai-spin 1s linear infinite;
}

.ai-generate-btn--disabled {
  color: var(--ai-color-disabled);
  cursor: not-allowed;
  opacity: 0.5;
}

.ai-generate-btn--disabled:hover {
  color: var(--ai-color-disabled);
  filter: none;
  transform: none;
}

.ai-generate-btn--disabled:hover .ai-generate-btn__icon {
  transform: none;
}

.ai-generate-btn--disabled:hover .ai-generate-btn__icon path {
  fill: transparent;
}

@keyframes ai-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ====================
   AI FIELD PANEL — Animations
   ==================== */

@keyframes aiShimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* AI field panel — detached card styling applied via .field-panel-card--ai */
.ai-field-panel {
  padding: 12px;
  animation: fieldPanelIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Prompt input row inside the panel */
.ai-field-panel__prompt-wrap {
  position: relative;
}

.ai-field-panel__input {
  display: block;
  width: 100%;
  padding: 10px 44px 10px 12px;
  font-family: inherit;
  font-size: 13px;
  background: var(--app-white);
  border: 1px solid rgba(180, 83, 9, 0.15);
  border-radius: var(--radius-sm);
  color: #1c1917;
  outline: none;
  resize: none;
  min-height: 38px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.ai-field-panel__input:focus-visible,
#editor-content .ai-field-panel__input:focus-visible {
  outline: var(--focus-ring-width) solid var(--ai-color-light);
  outline-offset: var(--focus-ring-offset);
  border-color: var(--ai-color-light);
  box-shadow: 0 0 0 3px var(--ai-glow);
}

.ai-field-panel__input::placeholder {
  color: #a8a29e;
}

.ai-field-panel__input:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Submit button inside prompt input */
.ai-field-panel__submit {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  background: var(--ai-color);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--app-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px var(--ai-glow);
  transition: all 0.2s ease;
}

.ai-field-panel__submit:hover {
  background: var(--ai-color-hover);
  box-shadow: 0 2px 8px var(--ai-glow-strong);
}

.ai-field-panel__submit:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}

/* Content area below prompt (chips or results) */
.ai-field-panel__content {
  animation: aiStateIn 0.2s ease-out;
}

/* Quick action chips */
.ai-field-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ai-field-panel__chip {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  color: var(--ai-color-text);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-field-panel__chip:hover {
  background: var(--ai-bg-hover);
  border-color: var(--ai-color);
  color: var(--ai-color);
  box-shadow: 0 2px 8px var(--ai-glow);
}

/* Suggestion rows (results) */
.ai-field-panel__suggestions {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-field-panel__suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border-bottom: 1px solid rgba(180, 83, 9, 0.08);
  transition: background 0.15s ease;
}

.ai-field-panel__suggestion:last-child {
  border-bottom: none;
}

.ai-field-panel__suggestion:hover {
  background: var(--ai-bg-hover);
}

.ai-field-panel__suggestion-text {
  font-size: 13px;
  color: #1c1917;
  flex: 1;
  line-height: 1.4;
}

.ai-field-panel__use-btn {
  background: var(--ai-color);
  border: none;
  color: var(--app-white);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 3px var(--ai-glow);
  transition: all 0.15s ease;
}

.ai-field-panel__use-btn:hover {
  background: var(--ai-color-hover);
  box-shadow: 0 2px 8px var(--ai-glow-strong);
}

/* Skeleton shimmer (amber-tinted) */
.ai-field-panel__skeleton {
  background: linear-gradient(90deg,
      var(--ai-bg-hover) 25%,
      var(--ai-bg) 50%,
      var(--ai-bg-hover) 75%);
  background-size: 200% 100%;
  animation: aiShimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  height: 18px;
}

/* "New prompt" link */
.ai-field-panel__new-prompt {
  background: none;
  border: none;
  color: var(--ai-color);
  opacity: 0.7;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 0 0 0;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.ai-field-panel__new-prompt:hover {
  opacity: 1;
  color: var(--ai-color-hover);
}

/* Error state */
.ai-field-panel__error {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--app-red-50);
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-field-panel__error-close {
  background: none;
  border: none;
  color: #991b1b;
  cursor: pointer;
  margin-left: auto;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.ai-field-panel__error-close:hover {
  opacity: 1;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

  .field-panel-card,
  .ai-generate-btn,
  .ai-field-panel,
  .ai-field-panel__chip,
  .ai-field-panel__submit,
  .ai-field-panel__use-btn {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* AI Upsell Panel (free editor)
   ========================================================================== */

.ai-field-panel__upsell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px;
  gap: 6px;
}

.ai-field-panel__upsell-heading {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-color);
}

.ai-field-panel__upsell-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--ai-color-light);
}

.ai-field-panel__upsell-text {
  font-size: 12px;
  color: var(--ai-color-text);
  line-height: 1.4;
  margin: 0;
  max-width: 280px;
}

.ai-field-panel__upsell-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-white);
  background: var(--ai-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: 0 1px 3px var(--ai-glow);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.ai-field-panel__upsell-cta:hover {
  background: var(--ai-color-hover);
  box-shadow: 0 2px 8px var(--ai-glow-strong);
  color: var(--app-white);
  text-decoration: none;
}

.ai-field-panel__upsell-cta svg {
  flex-shrink: 0;
}

.ai-field-panel__chips--preview {
  opacity: 0.4;
  pointer-events: none;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid rgba(180, 83, 9, 0.08);
}

/* Repeater Sections — duplicate removed; see sidebar-card repeater block above */