.am-form {max-width:980px; margin:0 auto;}
.am-field {margin: 10px 0;}
.am-field label {display:block; font-weight:600; margin-bottom:6px;}
.am-grid {display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px;}
.am-nav {margin-top: 20px; display:flex; gap:8px;}
.small {font-size:.85em; color:#444;}

/* step dots nav */
.am-steps-nav{display:flex;gap:14px;justify-content:center;margin:18px 0 10px}
.am-step-dot{display:flex;align-items:center;gap:8px;background:#f1f5f9;border:1px solid #e2e8f0;border-radius:22px;padding:6px 10px;cursor:pointer}
.am-step-dot span{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;background:#e2e8f0;color:#111;font-weight:700;font-size:12px}
.am-step-dot.is-current{background:#2563eb;color:#fff;border-color:#2563eb}
.am-step-dot.is-current span{background:#fff;color:#2563eb}

/* multistep visibilità */
.am-step{display:none;}
.am-step.is-current{display:block;}

/* repeater */
.am-co-wrap .am-row {border:1px solid #e5e7eb; padding:12px; margin-bottom:10px; border-radius:6px; background:#fbfbfb;}
.am-row-head {display:flex; justify-content:space-between; align-items:center; margin-bottom:8px;}
.am-actions .button {margin-left:6px;}
.am-row .am-grid {grid-template-columns:repeat(3,minmax(0,1fr));}

/* preview A4 */
.am-a4 {width:210mm; min-height:297mm; margin:0 auto; padding:15mm 18mm; background:#fff; color:#111; box-shadow:0 0 .5cm rgba(0,0,0,.1)}
.am-title{font-size:14pt; text-align:center; margin:6pt 0 10pt; font-weight:700;}
.am-authors{font-size:10.5pt; line-height:1.35; text-align:center; margin-bottom:8pt;}
.am-abs-text{font-family:"Times New Roman", Times, serif; font-size:11pt; text-align:justify; line-height:1.35;}
.am-figure-note{text-align:center; margin:10pt 0; font-size:9pt; color:#666;}
.am-foot{position:absolute; bottom:12mm; left:18mm; right:18mm; font-size:9pt; text-align:center; color:#888;}


/* v11: multistep + editors */
.am-step{ display:none; }
.am-step.is-current{ display:block; }

.am-field .wp-editor-wrap,
.am-field .wp-editor-container,
.am-field textarea.am-rich{ width:100%; max-width:100%; }
.am-field .wp-editor-tools{ display:block; overflow:visible; }
.am-field .wp-editor-tabs{ display:flex; gap:6px; }

.mce-tinymce { z-index: 0; }
.am-actions, .am-step .am-nav, .am-step .buttons { position: relative; z-index: 2; }
button.am-next, button.am-prev, .am-next, .am-prev { pointer-events:auto; cursor:pointer; }

/* Symbols dialog grid */
.am-sym-grid{ display:grid; grid-template-columns:repeat(12,1fr); grid-gap:6px; padding:6px; }
.am-sym{ font-size:18px; line-height:28px; height:32px; border:1px solid #ddd; background:#fff; cursor:pointer; border-radius:4px }
.am-sym:focus{ outline:2px solid #2271b1 }

/* v12: layout tidy + symbols grid 12 cols + title uppercase display */
.am-step{ display:none; }
.am-step.is-current{ display:block; }

/* Reduce gaps between labels and editors */
.am-field{ margin-bottom: 16px; }
.am-field label{ display:block; margin: 6px 0 4px; font-weight: 500; }
.am-field .wp-editor-wrap{ margin-top: 2px; overflow: visible; position: relative; z-index: 1; }
.am-field .wp-editor-tools{ display:block; }
.am-field .wp-editor-tabs{ display:flex; gap:6px; }
.am-field .wp-switch-editor{ position:relative; z-index:3; }

/* Editors full width */
.am-field .wp-editor-wrap,
.am-field .wp-editor-container,
.am-field textarea.am-rich{ width:100%; max-width:100%; box-sizing:border-box; }

/* Symbols dialog grid: 12 columns */
.am-sym-grid{ display:grid; grid-template-columns:repeat(12, minmax(28px,1fr)); grid-gap:6px; padding:6px; }
.am-sym{ font-size:18px; line-height:28px; height:32px; border:1px solid #ddd; background:#fff; cursor:pointer; border-radius:4px; }
.am-sym:focus{ outline:2px solid #2271b1; }

/* Prevent editor overlays from covering navigation */
.mce-tinymce{ z-index:0 !important; }
.am-actions, .am-step .am-nav, .am-step .buttons{ position:relative; z-index:2; }
button.am-next, button.am-prev, .am-next, .am-prev{ pointer-events:auto; cursor:pointer; }

/* Error visuals */
.am-error{ color:#b71c1c; font-size:12px; margin-top:4px; }
.am-invalid{ border-color:#b71c1c !important; background:#fff6f6; }


/* v16: tidy WP editor tabs and spacing in Step 3 */
.am-field .wp-editor-wrap{ overflow: visible; }
.am-field .wp-editor-tools{ display:block; margin: 4px 0; }
.am-field .wp-editor-tabs{ position: static; display:flex; gap:8px; margin: 0 0 6px; }
.am-field .wp-switch-editor{ position: static; }
.am-field label{ margin-bottom: 6px; }

/* Step 2 UX improvements */
.am-authors-grid{ display:grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap:14px; }
@media (max-width: 900px){ .am-authors-grid{ grid-template-columns:1fr; } }
.am-field.sm label{ font-size:.9rem; opacity:.85; }
.am-aff2-wrap{ display:none; margin-top:8px; border-left:3px solid #e3e7ef; padding-left:10px; }
.am-aff2-toggle{ display:flex; align-items:center; gap:8px; margin:8px 0 4px; }
#am-coauthors{ margin-top:10px; }
.am-co-row{ border:1px solid #e9edf5; border-radius:10px; padding:12px; margin:12px 0; background:#fafbff; }
.am-co-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.am-co-head h4{ margin:0; font-size:1rem; }
.am-btn{ display:inline-flex; align-items:center; gap:6px; padding:7px 10px; border:1px solid #d6dbe6; border-radius:8px; background:#fff; cursor:pointer; }
.am-btn:hover{ border-color:#c7ccda; }
.am-btn.primary{ background:#4c6fff; border-color:#4c6fff; color:#fff; }
.am-btn.ghost{ background:#fff; }
.am-modal{ position:fixed; inset:0; display:none; align-items:center; justify-content:center; z-index:99999; }
.am-modal.is-open{ display:flex; }
.am-modal::before{ content:""; position:absolute; inset:0; background:rgba(0,0,0,.35); }
.am-modal-card{ position:relative; width:min(680px, 95vw); background:#fff; border-radius:14px; box-shadow:0 10px 30px rgba(0,0,0,.15); padding:16px; z-index:1; }
.am-modal-card h3{ margin:0 0 10px; }
.am-modal-body{ display:grid; gap:10px; }
.am-radio-line{ display:flex; align-items:center; gap:8px; padding:8px; border:1px solid #e5e9f3; border-radius:8px; }
.am-preview{ font-size:.92rem; color:#3a3f51; }
.am-modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:12px; }


/* === Preview modal (Step 4) === */
#am-preview-modal{
  position: fixed !important;
  inset: 0;
  display: none; /* il JS imposta display:flex */
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0,0,0,0.55);
  z-index: 999999 !important;
  pointer-events: auto;
}

/* disattiva l'overlay generico di .am-modal per la preview */
#am-preview-modal::before{
  display:none !important;
}

#am-preview-modal .am-modal-inner{
  position: relative;
  background:#ffffff;
  color:#111;
  padding:32px 48px;
  max-width:900px;
  width:100%;
  max-height:90vh;
  overflow:auto;
  box-shadow:0 0 12px rgba(0,0,0,0.25);
  box-sizing:border-box;
  border-radius:0;
}

/* X di chiusura grande e centrata */
#am-preview-modal .am-close{
  position:absolute;
  top:14px;
  right:5px;
  width:36px;
  height:36px;
  border-radius:999px;
  border:1px solid #cbd5e1;
  background:#ffffff;
  color:#0f172a;
  font-size:20px;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index: 1000000;
}
#am-preview-modal .am-close:hover{
  background:#f1f5f9;
  border-color:#94a3b8;
}
