/* ═══════════════════════════════════════════
   Mail — Page d'envoi avec correction guidée
   ═══════════════════════════════════════════ */
:root {
  --bg:     #0d0d1a;
  --card:   #1e1e38;
  --card2:  #252545;
  --text:   #f0eeff;
  --text2:  #b8b0e0;
  --purple: #6c4de0;
  --teal:   #4ec9b0;
  --gold:   #ffd700;
  --coral:  #f48771;
  --border: rgba(255,255,255,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
  height: 100vh; overflow: hidden;
}

/* ── Écrans ── */
.ml-screen { display: none; width: 100%; height: 100vh; }
.ml-screen.active { display: flex; flex-direction: column; }

/* ══════════════════════════════════════════
   ÉCRAN PIN
   ══════════════════════════════════════════ */
#ml-pin { align-items: center; justify-content: center; }

.ml-pin-card {
  background: var(--card); border-radius: 24px;
  border: 1px solid var(--border);
  padding: 44px 36px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: 0 16px 64px rgba(0,0,0,.6);
}

.ml-pin-icon { font-size: 64px; }

.ml-pin-card h1 {
  font-family: 'Fredoka One', cursive; font-size: 2rem;
  background: linear-gradient(135deg, #fff 30%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.ml-pin-card p { font-size: .88rem; color: var(--text2); text-align: center; }

.ml-pin-input {
  width: 100%; background: var(--card2);
  border: 2px solid var(--border); border-radius: 12px;
  padding: 14px 18px; color: var(--text);
  font-size: 1.2rem; font-family: inherit; outline: none;
  text-align: center; letter-spacing: 6px;
  transition: border-color .2s;
}
.ml-pin-input:focus { border-color: var(--purple); }

.ml-pin-error {
  font-size: .85rem; color: var(--coral); min-height: 20px; text-align: center;
}

/* ══════════════════════════════════════════
   ÉCRAN COMPOSITION
   ══════════════════════════════════════════ */
#ml-compose { overflow: hidden; }

.ml-header {
  height: 52px; background: rgba(255,255,255,.04);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}

.ml-back {
  padding: 6px 14px; background: rgba(255,255,255,.08);
  border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: all .2s;
}
.ml-back:hover { background: rgba(255,255,255,.16); color: var(--text); }

.ml-header-title { font-weight: 700; font-size: 1rem; }

/* Zone formulaire scrollable */
.ml-form-wrap {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  display: flex; justify-content: center;
}

.ml-form {
  width: 100%; max-width: 680px;
  background: var(--card); border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  overflow: hidden; display: flex; flex-direction: column;
  min-height: fit-content;
}

/* Champs */
.ml-field {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.ml-field-body {
  flex: 1; align-items: flex-start; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.ml-label {
  font-size: .85rem; color: var(--text2); font-weight: 700;
  white-space: nowrap; min-width: 52px;
}

.ml-to-val {
  font-size: .95rem; font-weight: 700;
  color: var(--teal);
}

.ml-subject-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1rem; font-family: inherit;
}

.ml-body-input {
  flex: 1; width: 100%; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 1rem; font-family: inherit;
  resize: none; min-height: 200px; line-height: 1.8;
}

/* Actions */
.ml-actions {
  display: flex; gap: 10px; padding: 16px 20px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}

.ml-btn-check {
  padding: 12px 22px;
  background: rgba(255,255,255,.08); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: .95rem;
  font-family: inherit; cursor: pointer; transition: all .2s;
}
.ml-btn-check:hover { background: rgba(255,255,255,.15); }

.ml-btn-send {
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--purple), #3a1fa0);
  border: none; border-radius: 10px; color: #fff;
  font-size: .95rem; font-family: inherit;
  cursor: pointer; transition: transform .15s, opacity .2s;
  box-shadow: 0 4px 16px rgba(108,77,224,.4);
}
.ml-btn-send:hover:not(:disabled) { transform: scale(1.02); }
.ml-btn-send:disabled { opacity: .35; cursor: not-allowed; }

/* Status */
#ml-status {
  padding: 0 20px; font-size: .88rem; color: var(--text2);
  min-height: 32px; display: flex; align-items: center;
}

/* Erreurs */
#ml-errors-wrap { padding: 0 20px 16px; }

.ml-errors-title {
  font-size: .85rem; font-weight: 700; color: var(--coral);
  margin-bottom: 14px; padding-top: 4px;
}

.ml-err-card {
  background: var(--card2); border: 1px solid rgba(244,135,113,.2);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}

.ml-err-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}

.ml-err-word {
  font-family: 'Consolas', monospace; font-size: 1rem; font-weight: 700;
  color: var(--coral); background: rgba(244,135,113,.1);
  padding: 2px 8px; border-radius: 6px;
}

.ml-err-type {
  font-size: .75rem; color: var(--text2);
  background: rgba(255,255,255,.07); border-radius: 20px;
  padding: 3px 10px; border: 1px solid var(--border);
}

.ml-err-ctx {
  font-size: .85rem; color: var(--text2); margin-bottom: 12px;
  line-height: 1.55; font-style: italic;
}
.ml-err-ctx mark {
  background: rgba(244,135,113,.2); color: var(--coral);
  border-radius: 3px; padding: 0 3px; font-style: normal; font-weight: 700;
}

/* Cases de lettres (Wordle style) */
.ml-hint-boxes {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px;
}
.ml-hbox {
  width: 34px; height: 34px;
  border: 2px solid rgba(255,255,255,.15); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Consolas', monospace; font-size: 1rem; font-weight: 700;
  color: rgba(255,255,255,.2); background: rgba(255,255,255,.04);
  transition: all .25s;
}
.ml-hbox.revealed {
  background: rgba(78,201,176,.12); border-color: rgba(78,201,176,.45);
  color: var(--teal);
}
.ml-hbox.space-box { background: transparent; border: none; width: 10px; }

.ml-hint-row {
  display: flex; align-items: center; gap: 12px;
}

.ml-hint-count { font-size: .78rem; color: var(--text2); }

.ml-hint-btn {
  padding: 7px 14px;
  background: rgba(255,215,0,.08); border: 1px solid rgba(255,215,0,.25);
  border-radius: 8px; color: var(--gold); font-size: .82rem;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.ml-hint-btn:hover:not(:disabled) { background: rgba(255,215,0,.18); }
.ml-hint-btn:disabled { opacity: .45; cursor: not-allowed; }

.ml-btn-recheck {
  margin-top: 4px; padding: 10px 20px;
  background: rgba(255,255,255,.08); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text2); font-size: .88rem;
  font-family: inherit; cursor: pointer; transition: all .2s;
}
.ml-btn-recheck:hover { background: rgba(255,255,255,.15); color: var(--text); }

/* Message sans faute */
.ml-clean {
  margin: 0 20px 16px;
  background: rgba(78,201,176,.08); border: 1px solid rgba(78,201,176,.3);
  border-radius: 10px; padding: 14px 18px;
  font-size: .9rem; color: var(--teal); font-weight: 700;
}

/* ══════════════════════════════════════════
   ÉCRAN SUCCÈS
   ══════════════════════════════════════════ */
#ml-success { align-items: center; justify-content: center; }

.ml-success-card {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  text-align: center; padding: 48px 24px;
}

.ml-success-icon {
  font-size: 90px;
  animation: bounce .6s ease forwards;
}
@keyframes bounce {
  0%   { transform: scale(.3); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.ml-success-card h1 {
  font-family: 'Fredoka One', cursive; font-size: 2.2rem; color: var(--gold);
}

.ml-success-card p { font-size: 1rem; color: var(--text2); }

.ml-back-link {
  color: var(--text2); text-decoration: none; font-size: .88rem;
  transition: color .2s;
}
.ml-back-link:hover { color: var(--text); }

/* Bouton générique */
.ml-btn-primary {
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--purple), #3a1fa0);
  border: none; border-radius: 14px; color: #fff;
  font-size: 1rem; font-family: 'Fredoka One', 'Nunito', sans-serif;
  cursor: pointer; transition: transform .15s;
  box-shadow: 0 4px 20px rgba(108,77,224,.5);
}
.ml-btn-primary:hover { transform: scale(1.03); }
