/* ============================================================================
   FORM EDITOR — Dedicated screen styles
   Three-panel layout: field list | field editor | live preview
   ============================================================================ */

/* ---- AI Review slide-in panel ---- */

@keyframes fe-ai-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes fe-ai-dot-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

.fe-ai-review-panel {
  position: fixed;
  top: 56px;               /* sit below the header */
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 500;
  animation: fe-ai-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.fe-ai-review-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fe-ai-review-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #5b21b6;
}
.fe-ai-review-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(124, 58, 237, 0.3);
}
.fe-ai-review-subtitle {
  font-size: 11px;
  color: #7c3aed;
  font-weight: 500;
  opacity: 0.75;
  margin-top: 1px;
}
.fe-ai-review-close {
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  border-radius: 6px;
}
.fe-ai-review-close:hover { background: rgba(124, 58, 237, 0.08); color: #5b21b6; }

.fe-ai-review-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfc;
}

.fe-ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px 24px;
  color: #94a3b8;
}
.fe-ai-empty h4 {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  margin: 8px 0 2px;
}
.fe-ai-empty p { font-size: 12px; line-height: 1.5; max-width: 280px; }
.fe-ai-empty-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}
.fe-ai-empty-examples code {
  font-size: 11px;
  font-family: inherit;
  background: #f3e8ff;
  color: #5b21b6;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  border: 1px solid #e9d5ff;
  transition: all 0.15s;
}
.fe-ai-empty-examples code:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.fe-ai-msg { max-width: 92%; }
.fe-ai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  padding: 9px 14px;
  border-radius: 14px 14px 2px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.2);
}
.fe-ai-msg-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e9d5ff;
  color: #0f172a;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 2px;
  font-size: 13px;
  line-height: 1.55;
}

.fe-ai-proposal {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 12px;
}
.fe-ai-proposal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #047857;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.fe-ai-proposal-summary {
  color: #065f46;
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.4;
}
.fe-ai-proposal-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.fe-ai-proposal-key {
  font-size: 10px;
  font-family: ui-monospace, Consolas, monospace;
  background: #d1fae5;
  color: #047857;
  padding: 2px 6px;
  border-radius: 4px;
}
.fe-ai-proposal-actions {
  display: flex;
  gap: 6px;
}
.fe-ai-btn-apply {
  flex: 1;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #059669;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.fe-ai-btn-apply:hover:not(:disabled) { background: #047857; }
.fe-ai-btn-apply:disabled { opacity: 0.5; cursor: default; }
.fe-ai-btn-reject {
  padding: 7px 12px;
  font-size: 12px;
  color: #64748b;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
}
.fe-ai-applied-badge {
  font-size: 11px;
  color: #059669;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.fe-ai-typing {
  display: flex;
  align-self: flex-start;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 14px 14px 14px 2px;
}
.fe-ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a855f7;
  animation: fe-ai-dot-pulse 1.2s infinite ease-in-out;
}
.fe-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.fe-ai-typing span:nth-child(3) { animation-delay: 0.3s; }

.fe-ai-review-input-wrap {
  padding: 12px 14px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
.fe-ai-review-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fe-ai-review-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}
.fe-ai-review-send {
  margin-top: 8px;
  width: 100%;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}
.fe-ai-review-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.fe-ai-review-send:disabled { opacity: 0.5; cursor: wait; transform: none; }

.fe-ai-review-toggle {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
}
.fe-ai-review-toggle:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(124, 58, 237, 0.35); }



.ed-layout {
  display: flex;
  height: calc(100vh - 110px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
}

/* ---- Top toolbar ---- */

.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-quaternary);
  flex-wrap: wrap;
}

/* Form-level note strip just under the toolbar */
.ed-form-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: #fffdf7;
}

.ed-form-note-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.ed-form-note-input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  resize: vertical;
}

.ed-form-note-input:focus {
  outline: none;
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}

.ed-form-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-faint);
}
.ed-toolbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ed-toolbar-meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  align-items: center;
}
.ed-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #ede9fe;
  color: #5b21b6;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}
.ed-dirty-badge {
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
}

/* ---- Viewing-old-version banner ---- */

.ed-version-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  color: #713f12;
  font-size: 13px;
}
.ed-version-banner strong { color: #422006; }

/* ---- Left panel: field list ---- */

.ed-field-list-panel {
  width: var(--ed-list-width, 240px);
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-quaternary);
}
.ed-field-list-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ed-field-list-scroll {
  flex: 1;
  overflow-y: auto;
}
.ed-field-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-tertiary);
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 80ms;
  user-select: none;
}
.ed-field-item:hover { background: var(--bg-tertiary); }
.ed-field-item.selected {
  background: #ede9fe;
  border-left: 3px solid #7c3aed;
  padding-left: 7px;
  color: #5b21b6;
  font-weight: 500;
}
.ed-field-item.section { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.ed-field-item.section-end { color: var(--border-strong); font-size: 10px; }
.ed-field-item.indented { padding-left: 24px; }
.ed-field-item .ed-field-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-faint); }
.ed-field-item.selected .ed-field-icon { color: #7c3aed; }
.ed-field-item .ed-field-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-field-item .ed-link-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #7c3aed; flex-shrink: 0;
}
.ed-field-item .ed-link-dot.ed-link-dot-override {
  background: #f97316; /* orange-500 — distinguishes linked-with-override from clean linked */
  box-shadow: 0 0 0 1px #ffedd5;
}

/* "overridden" pill shown next to props that carry a per-form override */
.ed-override-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 8px;
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
  line-height: 1.4;
}
.ed-drag-handle { cursor: grab; color: var(--border-strong); flex-shrink: 0; }
.ed-drag-handle:hover { color: #7c3aed; }
.ed-drag-ghost { opacity: 0.4; background: #ede9fe; }
.ed-drag-chosen { background: #f5f3ff; }

/* Add-field button */
.ed-add-field-wrap { position: relative; padding: 8px 12px; }
.ed-add-field-menu {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
}
.ed-add-field-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.ed-add-field-option:hover { background: var(--bg-tertiary); }
.ed-add-field-option i { width: 16px; height: 16px; color: #7c3aed; }

/* ---- Center panel: field editor ---- */

.ed-editor-panel {
  width: var(--ed-editor-width, 400px);
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.ed-editor-content { padding: 16px; flex: 1; }
.ed-editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-faint);
  text-align: center;
  padding: 40px 20px;
}
.ed-editor-empty i { width: 40px; height: 40px; margin-bottom: 12px; }

/* Field property rows */
.ed-prop-row {
  margin-bottom: 12px;
}
.ed-prop-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.ed-prop-row input[type="text"],
.ed-prop-row input[type="number"],
.ed-prop-row select,
.ed-prop-row textarea {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-body);
}
.ed-prop-row input:focus,
.ed-prop-row select:focus,
.ed-prop-row textarea:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}
.ed-prop-row input:disabled,
.ed-prop-row select:disabled,
.ed-prop-row textarea:disabled {
  background: var(--bg-secondary);
  color: var(--text-faint);
  cursor: not-allowed;
}
.ed-prop-row .ed-lang-label {
  font-size: 10px;
  font-weight: 500;
  color: #7c3aed;
  margin-bottom: 2px;
}
.ed-prop-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--bg-quaternary);
}
.ed-prop-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* Editor actions bar */
.ed-actions {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-quaternary);
  flex-wrap: wrap;
}

/* ---- Right panel: live preview ---- */

.ed-preview-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
}
.ed-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-quaternary);
  font-size: 11px;
  color: var(--text-muted);
}
.ed-preview-iframe {
  flex: 1;
  border: 0;
  background: var(--bg-primary);
}
.ed-preview-toggle {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  background: none;
}
.ed-preview-toggle.active { background: #7c3aed; color: var(--bg-primary); border-color: #7c3aed; }
.ed-preview-toggle:not(.active) { color: var(--text-muted); border-color: var(--border); }

/* ---- Version history panel (slide-in overlay) ---- */

.ed-history-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.ed-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.ed-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.ed-history-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-tertiary);
  cursor: default;
}
.ed-history-item.current { background: #f5f3ff; }
.ed-history-ver {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ed-history-ver .badge { font-size: 9px; }
.ed-history-date { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.ed-history-notes { font-size: 11px; color: var(--text-secondary-soft); font-style: italic; margin-top: 2px; }
.ed-history-actions { display: flex; gap: 6px; margin-top: 6px; }

/* ---- Resize handles ---- */

.ed-resize-handle {
  width: 8px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
}
.ed-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: transparent;
  transition: background 150ms;
}
.ed-resize-handle:hover::after,
.ed-resize-handle.active::after {
  background: var(--color-primary);
}

/* ---- Responsive: hide preview on narrow screens ---- */
@media (max-width: 1100px) {
  .ed-preview-panel { display: none; }
  .ed-editor-panel { border-right: none; }
}
@media (max-width: 800px) {
  .ed-field-list-panel { width: 180px; }
  .ed-editor-panel { width: auto; flex: 1; }
}

/* ============================================================================
   Field search (top of left panel)
   ============================================================================ */
.ed-field-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
}
.ed-field-search-input {
  flex: 1;
  border: 1px solid transparent;
  background: #f1f5f9;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #0f172a;
  outline: none;
}
.ed-field-search-input:focus {
  background: #fff;
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}
.ed-field-search-clear {
  padding: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
}
.ed-field-search-clear:hover { color: #334155; }

/* ============================================================================
   Hotkey help overlay
   ============================================================================ */
.ed-hotkey-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ed-hotkey-panel {
  background: #fff;
  border-radius: 10px;
  width: min(480px, 92vw);
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}
.ed-hotkey-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
}
.ed-hotkey-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #334155;
}
.ed-hotkey-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ed-hotkey-row kbd {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 4px;
}
.ed-hotkey-row span { color: #334155; }
.ed-hotkey-footer {
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}
.ed-hotkey-footer kbd {
  display: inline-block;
  padding: 0 4px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  background: #e2e8f0;
  border-radius: 3px;
}

/* ============================================================================
   Version diff modal
   ============================================================================ */
.ed-diff-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ed-diff-modal {
  background: #fff;
  border-radius: 10px;
  width: min(1100px, 94vw);
  height: min(82vh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
}
.ed-diff-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 13px;
  color: #0f172a;
}
.ed-diff-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  color: #64748b;
  background: #fff;
}
.ed-diff-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}
.ed-diff-dot.removed { background: #fecaca; border: 1px solid #f87171; }
.ed-diff-dot.added { background: #bbf7d0; border: 1px solid #4ade80; }
.ed-diff-dot.modified { background: #fef08a; border: 1px solid #facc15; }
.ed-diff-dot.unchanged { background: #f1f5f9; border: 1px solid #cbd5e1; }
.ed-diff-body {
  flex: 1;
  overflow-y: auto;
  background: #fff;
  padding: 0;
}
.ed-diff-cols-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
  border-bottom: 1px solid #cbd5e1;
}
.ed-diff-col-title {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  border-right: 1px solid #cbd5e1;
}
.ed-diff-col-title:last-child { border-right: none; }
.ed-diff-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid #f1f5f9;
}
.ed-diff-cell {
  padding: 10px 12px;
  border-right: 1px solid #f1f5f9;
  font-size: 12px;
  min-height: 48px;
}
.ed-diff-cell:last-child { border-right: none; }
.ed-diff-cell.cell-removed { background: #fef2f2; }
.ed-diff-cell.cell-added { background: #f0fdf4; }
.ed-diff-cell.cell-modified { background: #fefce8; }
.ed-diff-field-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ed-diff-field-name code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #0f172a;
  font-weight: 600;
}
.ed-diff-type-badge {
  font-size: 10px;
  padding: 1px 6px;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 3px;
  font-weight: 600;
}
.ed-diff-req {
  font-size: 9px;
  color: #b91c1c;
  font-weight: 600;
  text-transform: uppercase;
}
.ed-diff-field-label {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}
.ed-diff-changes {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
  font-size: 11px;
}
.ed-diff-change-line {
  display: flex;
  gap: 6px;
  padding: 1px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.5;
}
.ed-diff-prop {
  color: #7c3aed;
  font-weight: 600;
  flex-shrink: 0;
}
.ed-diff-old-val {
  color: #b91c1c;
  text-decoration: line-through;
  text-decoration-color: rgba(185, 28, 28, 0.5);
  word-break: break-word;
}
.ed-diff-new-val {
  color: #15803d;
  word-break: break-word;
}
.ed-diff-placeholder {
  color: #cbd5e1;
  font-style: italic;
  font-size: 11px;
}
.ed-diff-footer {
  padding: 8px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 11px;
  color: #64748b;
}
/* ========================================================================
   AI Field Review — slide-in conversational panel
   ====================================================================== */
.fe-ai-review-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: 0;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.25);
}
.fe-ai-review-toggle:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(124, 58, 237, 0.35); }
.fe-ai-review-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.fe-ai-review-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100vw;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -6px 0 18px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 1500;
}

.fe-ai-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, #faf5ff, #ede9fe);
  border-bottom: 1px solid #e9d5ff;
}
.fe-ai-review-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: #5b21b6; }
.fe-ai-review-title-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; display: inline-flex; align-items: center; justify-content: center;
  color: #7c3aed; box-shadow: 0 1px 2px rgba(124, 58, 237, 0.2);
}
.fe-ai-review-subtitle { font-size: 10px; font-weight: 500; color: #7c3aed; margin-top: 2px; }

.fe-ai-review-header-actions { display: flex; align-items: center; gap: 6px; }
.fe-ai-cost-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 7px; border-radius: 10px;
  background: #fff; border: 1px solid #ddd6fe;
  font-size: 10px; font-weight: 600; color: #5b21b6;
}
.fe-ai-review-close {
  width: 24px; height: 24px; border-radius: 6px; border: 0;
  background: transparent; color: #6b21a8; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.fe-ai-review-close:hover { background: rgba(124, 58, 237, 0.1); }

.fe-ai-review-quick-actions {
  display: flex; gap: 6px; padding: 8px 14px;
  border-bottom: 1px solid #f3f4f6; background: #fafafa;
}
.fe-ai-quick-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 14px;
  background: #fff; border: 1px solid #e5e7eb;
  font-size: 10px; font-weight: 500; color: #475569;
  cursor: pointer;
}
.fe-ai-quick-btn:hover:not(:disabled) { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.fe-ai-quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.fe-ai-review-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: #fafafa;
}

.fe-ai-empty { text-align: center; padding: 24px 12px; color: #6b7280; }
.fe-ai-empty h4 { margin: 12px 0 6px; font-size: 14px; color: #374151; }
.fe-ai-empty p { font-size: 12px; line-height: 1.5; margin-bottom: 14px; }
.fe-ai-empty-examples { display: flex; flex-direction: column; gap: 6px; }
.fe-ai-empty-examples code {
  display: block; padding: 6px 10px; border-radius: 8px;
  background: #fff; border: 1px solid #e5e7eb;
  font-size: 11px; color: #6d28d9; font-family: inherit; cursor: pointer;
  text-align: left;
}
.fe-ai-empty-examples code:hover { background: #f5f3ff; border-color: #c4b5fd; }

.fe-ai-msg {
  max-width: 92%; padding: 9px 12px; border-radius: 12px;
  font-size: 12px; line-height: 1.5; word-wrap: break-word;
}
.fe-ai-msg-user { align-self: flex-end; background: #7c3aed; color: #fff; }
.fe-ai-msg-assistant { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; color: #111827; }

.fe-ai-proposal {
  margin-top: 10px; padding: 10px; border-radius: 8px;
  background: #f8fafc; border: 1px solid #e2e8f0;
}
.fe-ai-proposal-multi { background: #fdfaff; border-color: #ede9fe; }
.fe-ai-proposal-header {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: #7c3aed; margin-bottom: 6px;
}
.fe-ai-proposal-summary { font-size: 11px; color: #475569; font-style: italic; margin-bottom: 8px; }

.fe-ai-diff-table {
  display: flex; flex-direction: column; gap: 3px;
  margin: 6px 0; font-size: 10px; font-family: ui-monospace, SFMono-Regular, monospace;
}
.fe-ai-diff-row {
  display: grid;
  grid-template-columns: 90px 1fr 16px 1fr;
  gap: 6px; align-items: center;
  padding: 2px 0;
}
.fe-ai-diff-key { color: #64748b; font-weight: 600; }
.fe-ai-diff-before {
  background: #fee2e2; color: #991b1b; padding: 2px 6px; border-radius: 4px;
  text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fe-ai-diff-after {
  background: #dcfce7; color: #166534; padding: 2px 6px; border-radius: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fe-ai-diff-arrow { color: #94a3b8; text-align: center; font-size: 10px; }

.fe-ai-multi-entry {
  margin-top: 8px; padding: 8px; border-radius: 6px;
  background: #fff; border: 1px solid #ede9fe;
}
.fe-ai-multi-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; cursor: pointer; margin-bottom: 4px;
}
.fe-ai-multi-label input[type=checkbox] { accent-color: #7c3aed; }
.fe-ai-multi-label strong { color: #1e293b; font-family: ui-monospace, monospace; }
.fe-ai-multi-entry-summary { color: #64748b; font-size: 10px; font-style: italic; margin-left: 6px; }

.fe-ai-proposal-actions { display: flex; gap: 6px; margin-top: 8px; }
.fe-ai-btn-apply {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 6px; border: 0;
  background: #16a34a; color: #fff; font-size: 11px; font-weight: 600; cursor: pointer;
}
.fe-ai-btn-apply:hover:not(:disabled) { background: #15803d; }
.fe-ai-btn-apply:disabled { opacity: 0.5; cursor: not-allowed; }
.fe-ai-btn-reject {
  padding: 5px 10px; border-radius: 6px; border: 1px solid #e5e7eb;
  background: #fff; color: #64748b; font-size: 11px; cursor: pointer;
}
.fe-ai-btn-reject:hover { background: #f9fafb; }

.fe-ai-applied-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 4px 10px; border-radius: 12px;
  background: #dcfce7; color: #166534; font-size: 10px; font-weight: 600;
}

.fe-ai-typing { display: flex; gap: 4px; padding: 6px 10px; align-self: flex-start; }
.fe-ai-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #c4b5fd;
  animation: fe-ai-typing-bounce 1.2s infinite;
}
.fe-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.fe-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fe-ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.fe-ai-review-input-wrap {
  padding: 10px 12px; border-top: 1px solid #e5e7eb; background: #fff;
  display: flex; gap: 8px; align-items: flex-end;
}
.fe-ai-review-input {
  flex: 1; resize: none; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
.fe-ai-review-input:focus { border-color: #c4b5fd; }
.fe-ai-review-send {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-radius: 8px; border: 0;
  background: #7c3aed; color: #fff; font-size: 11px; font-weight: 600; cursor: pointer;
  height: 36px;
}
.fe-ai-review-send:hover:not(:disabled) { background: #6d28d9; }
.fe-ai-review-send:disabled { opacity: 0.5; cursor: not-allowed; }
