/* ─── Reusable Component Classes ─── */

/* ═══ Buttons ═══ */
.btn-app {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: var(--radius-pill);
  border: none;
  padding: 0.3rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  min-height: 32px;
  line-height: 1.45;
}

.btn-app:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}

.btn-app:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-app-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-app-secondary {
  background: var(--bg-muted);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-app-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

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

.btn-app-success:hover:not(:disabled) {
  background: #15803d;
}

.btn-app-danger {
  background: transparent;
  color: var(--danger);
}

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

.btn-app-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-app-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-main);
}

.btn-app-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-app-icon:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-main);
}

.btn-app-icon:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}

/* ═══ Inputs ═══ */
.input-app,
.select-app,
.textarea-app {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  line-height: 1.45;
  outline: none;
  background: var(--bg-subtle);
  color: var(--text-main);
  width: 100%;
  min-height: 34px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea-app {
  min-height: 60px;
  resize: vertical;
}

.input-app:focus,
.select-app:focus,
.textarea-app:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: #fff;
}

.input-app::placeholder {
  color: var(--text-faint);
}

.input-app-locked {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ═══ Panels / Cards ═══ */
.panel-app {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-header-app {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.panel-header-app h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.panel-header-app small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.panel-body-app {
  padding: 0.6rem 0.85rem 0.75rem;
  flex: 1;
  overflow: auto;
}

/* ═══ Sidebar ═══ */
.sidebar-app {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-item-app {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-subtle);
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.05s ease;
  font-size: 0.8125rem;
}

.sidebar-item-app:hover {
  background: #fff;
  border-color: var(--primary-border);
  transform: translateY(-1px);
}

.sidebar-item-active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

/* ═══ Reorder mode ═══ */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.drag-handle:hover { opacity: 1; }
.sidebar-item-app.reorderable { cursor: grab; }
.sidebar-item-app.reorderable:active { cursor: grabbing; }
.sidebar-item-app.dragging {
  opacity: 0.4;
  border-style: dashed;
}
.sidebar-item-app.drag-above {
  box-shadow: 0 -2px 0 0 var(--primary);
}
.sidebar-item-app.drag-below {
  box-shadow: 0 2px 0 0 var(--primary);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}
.panel-header-actions .btn-app {
  white-space: nowrap;
  font-size: 0.75rem;
}
#btn-reorder-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
}
.btn-app-icon.active,
#btn-reorder-toggle.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

/* ═══ Tabs ═══ */
.tabs-app {
  display: inline-flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}

.tab-app {
  border: none;
  background: transparent;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.tab-app-active {
  background: var(--primary);
  color: #fff;
}

.tab-app:not(.tab-app-active):hover {
  background: #e2e8f0;
}

/* ═══ Badges / Chips ═══ */
.badge-app {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: var(--radius-md);
  padding: 0.2rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-app-primary {
  background: var(--primary);
  color: #fff;
}

.badge-app-muted {
  background: #64748b;
  color: #fff;
}

.badge-app-light {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-app-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-app-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-app-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-app-info {
  background: var(--info-bg);
  color: var(--info-text);
}

/* ═══ Status pills (post list) ═══ */
.status-pill {
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #64748b;
  color: #fff;
}

.status-pill.status-publish { background: var(--success); color: #fff; }
.status-pill.status-draft { background: #ef4444; color: #fff; }
.status-pill.status-pending { background: #f59e0b; color: #fff; }
.status-pill.status-private { background: #64748b; color: #fff; }
.status-pill.status-trash { background: #dc2626; color: #fff; }

/* ═══ New post badge ═══ */
.new-badge {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.4rem;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* ═══ WooCommerce badge ═══ */
.woo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.5rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ═══ Stock badge ═══ */
.stock-badge {
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.45rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stock-badge.instock { background: var(--success); color: #fff; }
.stock-badge.outofstock { background: #dc2626; color: #fff; }
.stock-badge.onbackorder { background: #f59e0b; color: #fff; }

/* ═══ Post list components ═══ */
.post-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.post-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
}

.post-item-thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: 1rem;
}

.post-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-item-title {
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.post-item-meta .meta-sku {
  font-size: 0.625rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.post-item-meta .meta-date {
  font-size: 0.625rem;
  color: var(--text-faint);
}

.dirty-icon {
  font-size: 0.875rem;
}

/* ═══ Post filters ═══ */
.post-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 0 var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
}

.post-filters input,
.post-filters select {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
  background: var(--bg-subtle);
  width: 100%;
}

.post-filters input:focus,
.post-filters select:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: #fff;
}

/* ═══ Field groups ═══ */
.field-group {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-bottom: var(--space-2);
  background: #fdfdfd;
}

.field-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.field-group-header h3 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
}

.field-group-header span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

/* Add visual separation between ACF fields in structured field groups */
.field-group:not(.editor-overview-group):not(.editor-secondary-group) .field-row {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-faint, #f5f5f5);
}

.field-group:not(.editor-overview-group):not(.editor-secondary-group) .field-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.field-row label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.field-row label span.field-name {
  opacity: 0.5;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 400;
  color: var(--text-muted);
}

.field-required {
  color: var(--danger, #dc2626);
  font-weight: 700;
}

.field-row input,
.field-row textarea,
.field-row select {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
  outline: none;
  background: var(--bg-subtle);
  width: 100%;
  resize: vertical;
  min-height: 32px;
}

.field-row textarea {
  min-height: 60px;
}

.field-row input:focus,
.field-row textarea:focus,
.field-row select:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
  background: #fff;
}

.field-row input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
  align-self: flex-start;
  margin: 2px 0;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
}

.checkbox-grid label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-main);
  gap: var(--space-1);
}

.field-help {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.field-input-locked {
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

.json-field {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  min-height: 80px;
}

/* ═══ ACF field group sections ═══ */
.field-group section.mb-3 {
  margin-bottom: var(--space-3);
}

.field-group section.mb-3 > h3 {
  margin: 0 0 var(--space-2) 0;
  padding: var(--space-1) 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--primary);
}

.field-group section.mb-3 + section.mb-3 {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

/* ═══ ACF true_false toggle ═══ */
.acf-toggle-wrap {
  display: inline-flex !important;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  font-weight: 400 !important;
  color: var(--text-main) !important;
}

.acf-toggle-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.acf-toggle-track {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background: var(--bg-muted, #e2e8f0);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.acf-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
}

.acf-toggle-wrap input:checked + .acf-toggle-track {
  background: var(--primary);
  border-color: var(--primary);
}

.acf-toggle-wrap input:checked + .acf-toggle-track::after {
  transform: translateX(16px);
}

.acf-toggle-message {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ═══ ACF WYSIWYG container ═══ */
.acf-wysiwyg-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.acf-wysiwyg-container .tox-tinymce {
  border: none !important;
}

/* ═══ ACF date picker ═══ */
.field-row input[type="date"] {
  max-width: 220px;
}

/* ═══ Relationship / Post Object field editors ═══ */

.relationship-container,
.post-object-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.relationship-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}

.relationship-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px 6px 2px 8px;
  font-size: 0.75rem;
  color: var(--text-main);
  line-height: 1.4;
}

.chip-title {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 2px;
}

.chip-remove:hover {
  color: var(--danger, #dc3545);
  background: rgba(220, 53, 69, 0.1);
}

.relationship-search-wrap {
  position: relative;
}

.relationship-search {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  outline: none;
}

.relationship-search:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.relationship-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
}

.relationship-dropdown-item {
  padding: 6px 10px;
  font-size: 0.8125rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.relationship-dropdown-item:hover {
  background: var(--bg-muted);
}

.relationship-dropdown-item.selected {
  background: rgba(var(--primary-rgb, 59, 130, 246), 0.08);
  font-weight: 500;
}

.relationship-dropdown-loading,
.relationship-dropdown-empty {
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.relationship-type-badge {
  font-size: 0.625rem;
  background: var(--bg-muted);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* ═══ Image field editor ═══ */

.image-field-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.image-field-preview {
  min-height: 40px;
}

.image-field-thumb {
  max-width: 120px;
  max-height: 90px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  object-fit: cover;
}

.image-field-loading {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.image-field-controls {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.image-field-id-input {
  width: 80px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.25rem 0.4rem;
  font-size: 0.8125rem;
}

.btn-image-choose,
.btn-image-clear {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
}

.post-object-selection {
  min-height: 24px;
}

/* ═══ Editor footer ═══ */
.editor-footer {
  padding: var(--space-3) 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.status-bar {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.status-bar span.error { color: var(--danger); }
.status-bar span.success { color: var(--success); }

/* ═══ Featured media ═══ */
.media-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.media-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.featured-image-card {
  margin-bottom: var(--space-3);
}

.featured-image-top {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}

.featured-image-top.clickable {
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.featured-image-top.clickable:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.featured-image-top img {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}

.featured-image-actions {
  display: flex;
  gap: var(--space-2);
}

/* ═══ Media picker modal ═══ */
.media-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 980;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.media-picker-overlay.open { display: flex; }

.media-picker-modal {
  width: min(980px, 96vw);
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.media-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.media-picker-header h3 {
  margin: 0;
  font-size: 1rem;
}

.media-picker-toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.media-picker-toolbar input {
  flex: 1;
}

.media-picker-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.media-picker-body {
  padding: 0.75rem 0.85rem;
  overflow: auto;
  min-height: 280px;
}

.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: var(--space-3);
}

.media-picker-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.media-picker-item {
  position: relative;
}

.media-picker-item.selected {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.media-picker-item.excluded {
  opacity: 0.45;
  pointer-events: none;
}

.media-picker-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e2e8f0;
  display: block;
}

.media-picker-item-info {
  padding: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Multi-select checkbox indicator */
.media-picker-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.15s, border-color 0.15s;
}

.media-picker-check.checked {
  background: var(--primary);
  border-color: var(--primary);
}

.media-picker-check.checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* "Already added" badge */
.media-picker-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.media-picker-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.media-picker-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-3) 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ═══ Toast notifications ═══ */
.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bbf7d0; }
.toast.error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid #fecaca; }
.toast.info { background: var(--info-bg); color: var(--info-text); border: 1px solid #c7d2fe; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ═══ View mode toggle ═══ */
.view-toggle {
  display: inline-flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}

.view-toggle button {
  border: none;
  background: transparent;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.view-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.view-toggle button:not(.active):hover {
  background: #e2e8f0;
}

/* ═══ Content mode toggle ═══ */
.content-mode-toggle {
  display: inline-flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  margin-bottom: var(--space-1);
}

.content-mode-toggle button {
  border: none;
  background: transparent;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.content-mode-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.content-mode-toggle button:not(.active):hover {
  background: #e2e8f0;
}

/* ═══ Content views ═══ */
.content-raw-view {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  max-height: 400px;
  overflow: auto;
  min-height: 80px;
}

.content-preview-view {
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: #fff;
  min-height: 80px;
  max-height: 400px;
  overflow: auto;
  font-size: 0.9rem;
  line-height: 1.7;
  word-break: break-word;
}

.content-preview-view img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.content-preview-view h1, .content-preview-view h2, .content-preview-view h3 { margin-top: 0.75rem; margin-bottom: 0.35rem; }
.content-preview-view p { margin: 0 0 0.65rem; }

/* ═══ Preview card ═══ */
.preview-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 0;
  overflow: hidden;
}

.preview-hero {
  position: relative;
  padding: 1.25rem 1.5rem 1rem;
  background: linear-gradient(135deg, var(--bg-subtle), var(--bg-muted));
  border-bottom: 1px solid var(--border-subtle);
}

.preview-hero-inner {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.preview-hero-text {
  flex: 1;
  min-width: 0;
}

.preview-hero-text h1 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.preview-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.preview-thumb {
  width: 120px;
  height: 90px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
}

.preview-thumb-placeholder {
  width: 120px;
  height: 90px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: 0.8125rem;
  text-align: center;
}

.preview-content-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

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

.preview-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.preview-html-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-main);
  word-break: break-word;
}

.preview-html-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.preview-html-content h1, .preview-html-content h2, .preview-html-content h3 { margin-top: 1rem; margin-bottom: 0.5rem; }
.preview-html-content p { margin: 0 0 0.75rem; }
.preview-html-content ul, .preview-html-content ol { padding-left: 1.25rem; margin: 0 0 0.75rem; }

.preview-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

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

.preview-field-item {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
}

.preview-field-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.preview-field-value {
  font-size: 0.8125rem;
  color: var(--text-main);
  word-break: break-word;
}

.preview-field-value.mono {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
  background: var(--bg-muted);
  padding: 0.35rem;
  border-radius: var(--radius-xs);
  margin-top: var(--space-1);
}

.preview-tax-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.preview-tax-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid #c7d2fe;
}

.preview-tax-group { margin-bottom: var(--space-2); }

.preview-tax-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.preview-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.8125rem;
}

.minimal-preview-list { margin: 0; padding-left: 1.25rem; }
.minimal-preview-item { margin-bottom: var(--space-2); }

/* ═══ Divi locked field ═══ */
.field-row.divi-locked textarea {
  background: var(--bg-muted);
  color: var(--text-faint);
  cursor: not-allowed;
  border-color: var(--border-subtle);
  opacity: 0.7;
}

.divi-warning {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  font-size: 0.7rem;
  color: var(--warning-text);
  margin-bottom: var(--space-2);
}

.divi-warning svg { flex-shrink: 0; width: 14px; height: 14px; }

/* ═══ Editor open links ═══ */
.editor-open-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.editor-open-links a {
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
}

.editor-open-links a:hover {
  text-decoration: underline;
}

/* ═══ Date info ═══ */
.date-info {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: var(--space-1) 0;
}

/* ═══ Product price display ═══ */
.product-price-display {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--success-text);
}

.product-price-sale {
  text-decoration: line-through;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: var(--space-1);
}

/* ═══ Product images ═══ */
.product-images-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.product-gallery-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.product-gallery-thumb:hover {
  border-color: var(--primary);
}

/* ═══ Product field group ═══ */
.product-field-group {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary);
  padding: var(--space-3) var(--space-3) var(--space-2);
  margin-bottom: var(--space-3);
  background: var(--primary-light);
}

.product-field-group .field-group-header h3 {
  color: var(--primary);
}

/* ═══ WooCommerce fallback banner ═══ */
.woo-fallback-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0.85rem;
  border-radius: var(--radius-lg);
  background: var(--info-bg);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.75rem;
  margin-bottom: var(--space-3);
}

/* ═══ New post banner & sync CTA ═══ */
.new-post-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0.85rem;
  border-radius: var(--radius-lg);
  background: var(--info-bg);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.75rem;
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

.new-post-sync-cta {
  display: block;
  width: 100%;
  padding: var(--space-3);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: var(--space-3);
  cursor: pointer;
}

/* ═══ Trash panel ═══ */
.trash-view-link {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: var(--space-2);
  font-size: 0.7rem;
  opacity: 0.6;
}
.trash-view-link:hover { opacity: 1; }

.trash-panel {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.trash-panel-header {
  font-size: 0.75rem;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: 0.72rem;
}

.trash-item + .trash-item {
  border-top: 1px solid var(--border-subtle);
}

.trash-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.trash-item-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-item-meta {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.trash-item .btn-app {
  flex-shrink: 0;
  font-size: 0.65rem;
  padding: 2px 8px;
}

/* ═══ Field preview toggle ═══ */
.field-preview-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.15rem 0.25rem;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.field-preview-toggle:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.field-preview-toggle.active {
  color: var(--primary);
}

.field-inline-preview {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #fff;
  font-size: 0.8125rem;
  line-height: 1.6;
  word-break: break-word;
  max-height: 200px;
  overflow: auto;
  margin-top: var(--space-1);
}

.field-inline-preview img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ═══ Settings connected badge ═══ */
.settings-connected-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.7rem;
  color: var(--success-text);
  background: var(--success-bg);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
}

/* ═══ Site Manager (multi-site mode) ═══ */
.site-manager-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.site-manager-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
  font-size: 13px;
}
.site-manager-item .site-info { flex: 1; min-width: 0; }
.site-manager-item .site-name { font-weight: 500; }
.site-manager-item .site-url { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-manager-item .site-actions { display: flex; gap: 4px; }
.site-manager-item button {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--radius-xs);
  font-size: 12px;
}
.site-manager-item button:hover { background: var(--bg-muted); color: var(--text-main); }
.site-manager-item button.delete-site:hover { color: var(--danger); }

/* ═══ Rich Text Editor (TinyMCE) ═══ */
.rich-editor-container {
  border-radius: var(--radius-md);
  overflow: hidden;
}

.rich-editor-container .tox-tinymce {
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
}

.rich-editor-container .tox-tinymce:focus-within {
  border-color: var(--primary) !important;
  box-shadow: var(--focus-ring) !important;
}

.rich-editor-container .tox .tox-toolbar__primary {
  background: var(--bg-subtle) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

.rich-editor-container .tox .tox-edit-area__iframe {
  background: #fff !important;
}

/* ═══ Model Manager ═══ */

.model-mgr-loading,
.model-mgr-error,
.model-mgr-empty {
  padding: 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.model-mgr-error {
  color: var(--danger, #dc3545);
}

.model-mgr-section {
  margin-bottom: 16px;
}

.model-mgr-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.model-mgr-section-header h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.model-mgr-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-muted);
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 4px;
}

.model-mgr-actions {
  display: flex;
  gap: 4px;
}

.model-mgr-empty-list {
  padding: 10px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
}

.model-mgr-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-mgr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s;
}

.model-mgr-item:hover {
  border-color: var(--primary);
}

.model-mgr-item.inactive {
  opacity: 0.6;
}

.model-mgr-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.model-mgr-item-info strong {
  font-size: 0.8125rem;
}

.model-mgr-slug {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-mgr-icon {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.model-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
}

.model-badge-active {
  background: #dcfce7;
  color: #166534;
}

.model-badge-inactive {
  background: #f1f5f9;
  color: #64748b;
}

.model-mgr-item-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.model-mgr-footer {
  display: flex;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  min-height: 26px;
}

/* Model Editor Modal */
.model-editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(0,0,0,0.45);
}

.model-editor-overlay.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.model-editor-modal {
  display: none;
  background: var(--bg-main, #fff);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 95%;
  max-width: 640px;
  max-height: 85vh;
  overflow: hidden;
  flex-direction: column;
}

.model-editor-modal.open {
  display: flex;
}

.model-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.model-editor-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.model-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.model-editor-error {
  padding: 0 18px;
  color: var(--danger, #dc3545);
  font-size: 0.8125rem;
  min-height: 0;
}

.model-editor-error:not(:empty) {
  padding-bottom: 8px;
}

.model-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
}

/* Model Form */
.model-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.model-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-main);
}

.model-form input[type="text"],
.model-form textarea,
.model-form select {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.8125rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  transition: border-color 0.15s;
}

.model-form input[type="text"]:focus,
.model-form textarea:focus,
.model-form select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: var(--focus-ring);
}

.model-form input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

.model-form-row {
  display: flex;
  flex-direction: column;
}

.model-form-row-half {
  flex-direction: row;
  gap: 10px;
}

.model-form-row-half > label {
  flex: 1;
}

.model-form-section {
  margin-top: 4px;
}

.model-form-section h5 {
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text-main);
}

.model-checks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.model-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 5px !important;
  font-size: 0.8125rem;
  font-weight: 400 !important;
  cursor: pointer;
}

.model-check input[type="checkbox"] {
  margin: 0;
}

/* Template Picker */
.model-template-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-template-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.model-template-card:hover {
  border-color: var(--primary);
  background: var(--bg-subtle);
}

.model-template-icon {
  font-size: 24px;
  color: var(--primary);
  flex-shrink: 0;
}

.model-template-info strong {
  font-size: 0.875rem;
}

.model-template-info div {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.model-template-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ═══ Taxonomy chips (editor) ═══ */
.taxonomy-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.taxonomy-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.taxonomy-chip-toggle {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.taxonomy-chip-toggle:hover {
  border-color: var(--primary);
}

.taxonomy-chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ═══ Taxonomy section spacing ═══ */
.taxonomy-section {
  margin-bottom: var(--space-2);
}

.taxonomy-section .field-row {
  margin-bottom: 4px;
}

/* ═══ Editor overview group (Tier 1 — no chrome) ═══ */
.editor-overview-group {
  border: none;
  padding: 0;
  margin-bottom: var(--space-1);
  background: transparent;
}

.editor-overview-group > .field-group-header {
  display: none;
}

/* ═══ Editor secondary group (Tier 3 — de-emphasized) ═══ */
.editor-secondary-group {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}

.editor-secondary-group .field-group-header h3 {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.editor-secondary-group .field-row label {
  font-size: 0.7rem;
  color: var(--text-faint);
}

.editor-secondary-group .field-row input,
.editor-secondary-group .field-row select {
  font-size: 0.8125rem;
}

/* ═══ Featured image inline (compact) ═══ */
.featured-image-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.featured-image-thumb-sm {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.featured-image-actions-inline {
  display: flex;
  gap: var(--space-1);
}

/* ═══ Gallery field ═══ */
.gallery-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: var(--space-2);
}

.gallery-cell {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  cursor: grab;
  aspect-ratio: 1;
}

.gallery-cell:active { cursor: grabbing; }

.gallery-cell.gallery-dragging {
  opacity: 0.4;
}

.gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.gallery-cell:hover .gallery-remove {
  opacity: 1;
}

/* ═══ Collapsible sections ═══ */
.editor-section-collapsible {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
  background: var(--bg-subtle);
}

.editor-section-collapsible summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.editor-section-collapsible summary::-webkit-details-marker { display: none; }

.editor-section-collapsible summary::after {
  content: '\25B6';
  font-size: 0.55rem;
  transition: transform 0.2s;
  color: var(--text-faint);
}

.editor-section-collapsible[open] summary::after {
  transform: rotate(90deg);
}

.editor-section-collapsible > .field-group {
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  margin-bottom: 0;
}

.editor-section-collapsible > .product-images-row {
  padding: var(--space-2) var(--space-3);
}

/* ═══ Sticky editor header ═══ */
.main-canvas .panel-header-app {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-panel);
}

/* ═══ Workspace Switcher ═══ */
.workspace-switcher {
  display: inline-flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  margin-right: var(--space-2);
}

.workspace-switcher button {
  border: none;
  background: transparent;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.workspace-switcher button.active {
  background: var(--primary);
  color: #fff;
}

.workspace-switcher button:not(.active):hover {
  background: #e2e8f0;
}

/* ═══ Variables Workspace (inside editor panel) ═══ */
.variables-workspace {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--space-3);
}

.variables-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.variables-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.variables-header small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.variables-header-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.variables-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.variables-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.variables-section-title {
  margin: 0 0 var(--space-2) 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ─── Color Fields ─── */
.color-field-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0;
}

.color-field-row + .color-field-row {
  border-top: 1px solid var(--border-faint, #f0f0f0);
}

.color-field-label {
  flex: 0 0 140px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-main);
}

.color-picker-input {
  width: 36px;
  height: 30px;
  padding: 1px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}

.color-hex-input {
  width: 100px;
  font-family: monospace;
  font-size: 0.8125rem;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ─── Variable Fields ─── */
.variable-field-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.variable-field-row + .variable-field-row {
  border-top: 1px solid var(--border-faint, #f0f0f0);
}

.variable-field-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-main);
}

/* ─── Asset Fields ─── */
.asset-field-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0;
}

.asset-field-row + .asset-field-row {
  border-top: 1px solid var(--border-faint, #f0f0f0);
}

.asset-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.asset-preview img {
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-muted);
  padding: 4px;
}

/* ─── Variable Source List (sidebar) ─── */
.variables-source-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
}

.source-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.source-card:hover {
  border-color: var(--primary);
  background: var(--bg-panel);
}

.source-card.active {
  border-color: var(--primary);
  background: var(--bg-panel);
  box-shadow: 0 0 0 1px var(--primary);
}

.source-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.source-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.source-card-text strong {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.source-card-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Variable Field Header ─── */
.variable-field-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Asset Actions ─── */
.asset-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-app-danger-text {
  color: var(--danger, #dc3545);
}

.btn-app-sm {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
}

/* ─── Admin Panel ─── */
.variables-admin-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.variables-admin-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.admin-variable-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.5rem 0;
}

.admin-variable-row + .admin-variable-row {
  border-top: 1px solid var(--border-faint, #f0f0f0);
}

.admin-variable-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1;
}

.admin-variable-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.admin-variable-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.admin-var-preview {
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.admin-variable-action {
  flex-shrink: 0;
}

.admin-state-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-state-default {
  background: var(--bg-muted, #eee);
  color: var(--text-muted);
}

.admin-state-exposed {
  background: var(--success-bg, #d4edda);
  color: var(--success, #28a745);
}

.admin-state-hidden .admin-variable-label {
  opacity: 0.6;
}

.btn-app-warning {
  background: var(--warning, #ffc107);
  color: #333;
  border-color: var(--warning, #ffc107);
}

/* ─── Variable Media Picker Modal (scoped to avoid conflict with post media picker) ─── */
.var-media-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.var-media-picker-modal {
  background: var(--bg-panel, #fff);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.var-media-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.var-media-picker-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.var-media-picker-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.3rem;
  line-height: 1;
}

.var-media-picker-close:hover {
  color: var(--text-main);
}

.var-media-picker-search {
  padding: var(--space-2) var(--space-3);
}

.var-media-picker-status {
  padding: 0 var(--space-3);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.var-media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  padding: var(--space-2) var(--space-3);
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}

.var-media-picker-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-muted, #f5f5f5);
  transition: border-color 0.15s;
}

.var-media-picker-thumb:hover {
  border-color: var(--primary);
}

.var-media-picker-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.var-media-picker-footer {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
}

/* ═══ Tools Dropdown ═══ */
.tools-dropdown {
  position: relative;
}

.tools-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  min-width: 160px;
  margin-top: 4px;
  padding: var(--space-1) 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.tools-dropdown.open .tools-dropdown-menu {
  display: block;
}

.tools-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
}

.tools-dropdown-item:hover {
  background: var(--bg-muted);
}

/* ═══ Image Generator Modal ═══ */
.imagegen-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  justify-content: center;
  align-items: center;
}

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

.imagegen-modal {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

.imagegen-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.imagegen-modal-header h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.imagegen-modal-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.imagegen-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: calc(-1 * var(--space-2));
}

.imagegen-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-main);
  cursor: pointer;
}

.imagegen-context-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: calc(-1 * var(--space-2));
}

.imagegen-row {
  display: flex;
  gap: var(--space-3);
}

.imagegen-row-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.imagegen-btn-full {
  width: 100%;
  justify-content: center;
}

.imagegen-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.imagegen-preview img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.imagegen-revised {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.imagegen-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ═══ Button Loading State ═══ */
.btn-loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

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

.btn-loading-subtext {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-1);
}

/* ═══ Fill Fields Modal ═══ */
.fillfields-modal {
  max-width: 520px;
}

.fillfields-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-main);
}

.fillfields-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-3) 0;
  margin: 0;
}

.fillfields-field-row {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.fillfields-field-row:last-child {
  border-bottom: none;
}

.fillfields-field-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  cursor: pointer;
  margin-bottom: var(--space-1);
}

.fillfields-field-label strong {
  font-weight: 600;
  color: var(--text-main);
}

.fillfields-preview {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 1.4rem;
  overflow: hidden;
}

.fillfields-preview:not(.expanded) {
  max-height: 4.5em;
}

.fillfields-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  padding-left: 1.4rem;
  margin-top: 2px;
}

.fillfields-toggle:hover {
  text-decoration: underline;
}

.fillfields-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ─── Empty State ─── */
.variables-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-2);
}
/* One Up Admin SSO bootstrap. The existing Canvas UI remains untouched behind
   this gate until the same-origin server session has been established. */
.auth-pending .app-shell {
  visibility: hidden;
}

.website-console-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-app, #f5f7fa);
}

.website-console-auth-gate[hidden] {
  display: none;
}

.website-console-auth-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--border-color, #dfe3e8);
  border-radius: 14px;
  background: var(--bg-panel, #fff);
  box-shadow: 0 18px 48px rgba(20, 32, 48, 0.14);
  text-align: center;
}

.website-console-auth-card h1 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.website-console-auth-card p {
  margin: 0 0 22px;
  color: var(--text-muted, #667085);
}
