:root {
  --paper: #eef1f5;
  --surface: #ffffff;
  --ink: #18202e;
  --muted: #5a6477;
  --line: #d5dbe5;
  --accent: #2743c9;
  --accent-soft: #e3e8fb;

  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10151f;
    --surface: #182030;
    --ink: #e7ecf4;
    --muted: #95a0b4;
    --line: #26304a;
    --accent: #8ea3ff;
    --accent-soft: #232d4d;
  }
}
:root[data-theme="dark"] {
  --paper: #10151f;
  --surface: #182030;
  --ink: #e7ecf4;
  --muted: #95a0b4;
  --line: #26304a;
  --accent: #8ea3ff;
  --accent-soft: #232d4d;
}

*, *::before, *::after { box-sizing: inherit; }

html { -webkit-text-size-adjust: 100%; }

/* Les classes qui fixent `display` ne doivent pas annuler l'attribut hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

.masthead,
main {
  max-width: 36rem;
  margin: 0 auto;
  padding-inline: max(1.25rem, env(safe-area-inset-left, 0px));
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-top: 1.5rem;
}

.nav {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
}
.nav-settings {
  color: var(--accent);
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}

.nav-reviews {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
}

.badge {
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  font-size: 0.8rem;
  text-align: center;
}

.date {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.date::first-letter { text-transform: uppercase; }

main { padding-bottom: 3rem; }

.state {
  color: var(--muted);
  margin-top: 2rem;
}

/* ---------- Entrée mise en avant ---------- */

.featured { margin-top: 0.75rem; }

.meta {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.term {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 11vw, 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.definition {
  margin: 1rem 0 0;
  font-size: 1.2rem;
  line-height: 1.45;
}

.examples {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.1rem;
}

.example-text {
  margin: 0;
  font-size: 1.1rem;
}

mark {
  background: none;
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.18em;
  text-underline-offset: 0.2em;
}

.example-translations {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.reveal {
  margin-top: 1.75rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.reveal summary {
  padding: 0.9rem 0;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}
.reveal summary::-webkit-details-marker { display: none; }
.reveal[open] summary { color: var(--muted); font-weight: 500; }
.translation {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.25;
}

.note {
  margin: 1.5rem 0 0;
  padding: 0.9rem 1rem;
  background: var(--accent-soft);
  border-radius: 0.75rem;
  font-size: 0.98rem;
}

/* ---------- Actions ---------- */

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1.75rem;
}

.actions button {
  appearance: none;
  min-height: 3rem;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 1rem/1.2 var(--font-text);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.actions button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}
.actions button:disabled { opacity: 0.6; }

.status-line {
  min-height: 1.4em;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Autres entrées du jour ---------- */

.more { margin-top: 3rem; }

.more h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.more-list {
  display: grid;
  gap: 0.6rem;
}

.compact {
  background: var(--surface);
  border-radius: 1rem;
  padding: 0 1rem;
}
.compact > summary {
  padding: 1rem 0;
  cursor: pointer;
  list-style: none;
}
.compact > summary::-webkit-details-marker { display: none; }
.compact-term {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.15;
}
.compact .meta { margin: 0.15rem 0 0; font-size: 0.88rem; }
.compact-body { padding-bottom: 1.25rem; }
.compact-body .definition { margin-top: 0; font-size: 1.08rem; }
.compact-body .examples { margin-top: 1rem; }
.compact-body .reveal { margin-top: 1.25rem; }

/* ---------- Mot du jour : se tester avant de voir le sens ---------- */

.pronunciation {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
}
.ipa { font-size: 1.05rem; }

.speak {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 1.15rem;
  cursor: pointer;
}

.reveal-prompt { margin-top: 1.75rem; }
.reveal-question {
  margin: 0 0 0.25rem;
  font-weight: 600;
}
.reveal-prompt .show-answer { margin-top: 0.5rem; }

.example-translation {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.discover .definition { margin-top: 1.75rem; }
.discover .translation { margin: 1rem 0 0; }
.compact-body.discover .definition { margin-top: 1.25rem; }

/* ---------- Révisions ---------- */

.reviews-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: 1rem;
  background: var(--accent);
  color: var(--paper);
  font-weight: 650;
  text-decoration: none;
}

.back-link {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.25rem 0;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.review { margin-top: 1rem; }
.review .examples { margin-top: 1.25rem; }

.show-answer {
  appearance: none;
  width: 100%;
  min-height: 3rem;
  margin-top: 2rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  font: 600 1rem/1.2 var(--font-text);
  cursor: pointer;
}

.review-answer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.review-answer .definition { margin-top: 0; }
.review-translation { margin: 1rem 0; }

.grades { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.grades button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding-inline: 0.3rem;
  font-size: 0.92rem;
  border-radius: 1rem;
}
.grade-interval {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}
.grades button[data-grade="again"] { border-color: #d9534f; }
@media (max-width: 22rem) {
  .grades { grid-template-columns: 1fr 1fr; }
}

.grades-3 { grid-template-columns: repeat(3, 1fr); }
.grades-1 { grid-template-columns: 1fr; }
@media (max-width: 22rem) {
  .grades-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- Connexion ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: start center;
  padding: max(3rem, env(safe-area-inset-top, 0px)) 1.25rem 2rem;
  background: var(--paper);
  overflow-y: auto;
}
.login-box { width: 100%; max-width: 26rem; }
.login-box .term { font-size: clamp(2.2rem, 10vw, 3rem); }
.link-button.logout { justify-self: start; margin-top: 0.5rem; padding-left: 0; }

/* ---------- Réglages ---------- */

.settings-title {
  margin: 1.75rem 0 0;
  font-size: 1.1rem;
}
.settings-group {
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}
.settings-group legend {
  margin-bottom: 0.5rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}
.settings-option {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 3.5rem;
  margin-top: 0.45rem;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  cursor: pointer;
}
.settings-option > span { display: grid; gap: 0.1rem; }
.settings-option input {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  accent-color: var(--accent);
}

/* ---------- Entraînement ---------- */

.practice-link {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.4rem 0;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.practice-footer { margin: 2.5rem 0 0; text-align: center; }
.practice-footer .practice-link { margin-top: 0; font-size: 0.95rem; }

.practice-choices {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.practice-choice {
  appearance: none;
  display: grid;
  gap: 0.15rem;
  justify-items: start;
  min-height: 3.5rem;
  padding: 0.8rem 1.1rem;
  border: 1.5px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--ink);
  font: 600 1.05rem/1.2 var(--font-text);
  text-align: left;
  cursor: pointer;
}

.missed-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 1.1rem;
  font-weight: 600;
}

/* ---------- Exercices à choix, écoute, remise en ordre, associations ---------- */

.options {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}
.option, .tile, .match-item, .listen-button {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.option {
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font: 500 1.05rem/1.3 var(--font-text);
  text-align: left;
  overflow-wrap: anywhere;
}
.option:disabled, .tile:disabled, .match-item:disabled { cursor: default; }
.option.is-correct, .match-item.is-matched {
  border-color: #3f9d6a;
  background: color-mix(in srgb, #3f9d6a 14%, var(--surface));
  color: var(--ink);
}
.option.is-wrong, .match-item.is-wrong {
  border-color: #d9534f;
  background: color-mix(in srgb, #d9534f 14%, var(--surface));
}
.option:disabled:not(.is-correct):not(.is-wrong) { opacity: 0.55; }

.listen-button {
  width: 100%;
  min-height: 4rem;
  margin-top: 0.5rem;
  border-radius: 1rem;
  font: 600 1.2rem/1.2 var(--font-text);
}

.order-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 3.5rem;
  margin-top: 1rem;
  padding: 0.6rem;
  border: 1.5px dashed var(--line);
  border-radius: 1rem;
}
.order-placeholder { align-self: center; color: var(--muted); font-size: 0.92rem; }
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.tile {
  min-height: 2.75rem;
  padding: 0.45rem 0.85rem;
  border-radius: 0.75rem;
  font: 600 1.05rem/1.2 var(--font-text);
}
.tiles .tile:disabled { visibility: hidden; }
.tile.placed { border-color: var(--accent); background: var(--accent-soft); }

.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}
.match-column { display: grid; gap: 0.5rem; align-content: start; }
.match-item {
  min-height: 3.25rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.9rem;
  font: 500 0.98rem/1.25 var(--font-text);
  text-align: left;
  overflow-wrap: anywhere;
}
.match-item.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.match-item.is-matched { opacity: 0.6; }

/* ---------- Exercices à saisie ---------- */

.cloze-sentence {
  margin: 1.25rem 0 0;
  font-size: 1.3rem;
  line-height: 1.5;
}
.blank {
  display: inline-block;
  min-width: 4.5em;
  border-bottom: 2px solid var(--accent);
  color: transparent;
  line-height: 1.1;
}

.production-translation {
  margin: 1rem 0 0;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
}

.hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.answer-form {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.25rem;
}
.answer-input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  /* 16 px minimum : en dessous, Safari iOS zoome sur le champ. */
  font: 500 1.15rem/1.3 var(--font-text);
}
.answer-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.answer-form .show-answer { margin-top: 0; }

.link-button {
  appearance: none;
  justify-self: center;
  min-height: 2.75rem;
  padding: 0.4rem 0.8rem;
  border: 0;
  background: none;
  color: var(--accent);
  font: 600 0.95rem/1.2 var(--font-text);
  cursor: pointer;
}
.review-actions .link-button { display: block; margin: 0.5rem auto 0; }

.feedback:empty { display: none; }
.feedback {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  border: 1.5px solid var(--line);
}
.feedback p { margin: 0; overflow-wrap: anywhere; }
.feedback .feedback-detail { margin-top: 0.35rem; color: var(--muted); font-size: 0.95rem; }
.feedback.ok { border-color: #3f9d6a; }
.feedback.ko { border-color: #d9534f; }

.answer-term {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.answer-examples { margin-top: 1rem; }

.review-done { margin-top: 1.5rem; }

/* ---------- Résultats du quiz, fin de séance ---------- */

.option.is-selected { border-color: var(--accent); background: var(--accent-soft); }

.results-list {
  display: grid;
  gap: 0.6rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}
.result {
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}
.result.ko { border-color: #d9534f; }
.result-head { margin: 0; overflow-wrap: anywhere; }
.result-mark { display: inline-block; width: 1.4rem; font-weight: 700; }
.result.ok .result-mark { color: #3f9d6a; }
.result.ko .result-mark { color: #d9534f; }
.result-type { color: var(--muted); font-size: 0.9rem; }
.result-detail { margin-top: 0.5rem; font-size: 0.97rem; }
.result-detail p { margin: 0.35rem 0 0; overflow-wrap: anywhere; }
.result-detail .note { margin-top: 0.6rem; }
.result-detail .link-button { margin-top: 0.4rem; }

.done-group h2 {
  margin: 1.5rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}

.link-button.retire {
  display: block;
  margin: 2rem auto 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.88rem;
}
.review-done .term { font-size: clamp(2rem, 9vw, 2.75rem); }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
