:root {
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #243042;
  --muted: #6b7688;
  --accent: #3b6ea5;
  --accent-2: #e8a23b;
  --ok: #3f9d58;
  --bad: #d9534f;
  --line: #e4ded2;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--accent); color: #fff;
}
.app-header h1 { font-size: 1.1rem; margin: 0; }
.header-info { font-size: .85rem; opacity: .9; }

.app-main {
  padding: 16px;
  padding-bottom: 88px;
  max-width: 640px;
  margin: 0 auto;
}

.loading { color: var(--muted); text-align: center; margin-top: 40px; }

/* Cartes & sections */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.card p.sub { color: var(--muted); margin: 4px 0 12px; font-size: .9rem; }

/* Boutons */
button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 12px 16px;
  background: var(--accent); color: #fff; font-weight: 600;
  width: 100%;
}
.btn.secondary { background: #eef1f5; color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.btn + .btn { margin-top: 8px; }

/* Formulaire */
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], select {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font: inherit;
}

/* Sondage / coches */
.check-grid { display: grid; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff;
}
.check input { width: 20px; height: 20px; }
.cat-title { font-weight: 700; margin: 16px 0 8px; }

/* Pastilles de progrès */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .8rem; padding: 4px 10px; border-radius: 999px;
  background: #eef1f5; color: var(--accent);
}
.chip.box-1 { background: #fdecec; color: var(--bad); }
.chip.box-5 { background: #e7f4ea; color: var(--ok); }

/* Jeu vocabulaire */
.flashcard {
  text-align: center; padding: 28px 16px;
}
.flashcard .emoji { font-size: 4rem; }
.flashcard .word { font-size: 2rem; font-weight: 800; margin: 8px 0; }
.flashcard .prompt { color: var(--muted); }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.answer {
  padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; font-weight: 600;
}
.answer.ok { background: #e7f4ea; border-color: var(--ok); }
.answer.bad { background: #fdecec; border-color: var(--bad); }
.progress-bar { height: 8px; background: #eef1f5; border-radius: 8px; overflow: hidden; margin: 4px 0 16px; }
.progress-bar > i { display: block; height: 100%; background: var(--accent-2); }

.banner {
  padding: 10px 12px; border-radius: 12px; margin-bottom: 12px;
  background: #fff8ea; border: 1px solid #f0e2c0; color: #8a6d2f; font-size: .9rem;
}

/* Barre d'onglets */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
.tab {
  border: none; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 1.3rem; padding: 6px 10px; border-radius: 10px;
}
.tab span { font-size: .7rem; }
.tab.active { color: var(--accent); }

.print-root { position: absolute; left: -10000px; top: 0; }

/* Spinner de génération */
.spinner-wrap { text-align: center; padding: 20px; }
.spinner {
  width: 38px; height: 38px; margin: 0 auto 10px;
  border: 4px solid #e4ded2; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
