/* Chapitre — thème clair uniquement, fond blanc, accent pamplemousse. */
:root {
  --accent: #ff5e62;
  --accent-2: #ff9966;
  --accent-soft: #fff1ee;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --line: #ececf0;
  --ok: #2e9e5b;
  --warn: #c77700;
  --bad: #c23b3b;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #ffffff;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 .2rem; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.muted { color: var(--muted); font-size: .88rem; }
.error { color: var(--bad); font-size: .9rem; }
.empty { padding: .4rem 0; }

/* ---------- barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.05rem; color: var(--ink);
}
.brand-icon {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.topnav { display: flex; align-items: center; gap: 1rem; }
.topnav a { color: var(--muted); font-size: .92rem; }
.topnav a.active { color: var(--accent); font-weight: 600; }
.topnav form { display: inline; }
.linklike {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font-size: .92rem; font-family: inherit;
}

.page { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.back { display: inline-block; margin-bottom: .8rem; font-size: .9rem; }

/* ---------- boutons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: .65rem 1.1rem;
  font-size: .95rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 2px 8px rgba(255, 94, 98, .3);
}
.btn-primary:active { transform: scale(.97); }

/* ---------- carte mise à jour ---------- */
.maj-card {
  border: 1px solid var(--line); border-radius: 16px;
  padding: 1rem; margin-bottom: 1.2rem;
  background: linear-gradient(180deg, #fff, var(--accent-soft));
}
.maj-head { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; align-items: flex-start; }
.maj-form { display: flex; flex-direction: column; gap: .5rem; min-width: 240px; flex: 1; max-width: 340px; }
.maj-form textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem;
  font-family: inherit; font-size: .88rem; resize: vertical; background: #fff;
}
.maj-summary { font-size: .92rem; margin: .8rem 0 0; }
.maj-running { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--accent); flex-wrap: wrap; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  display: inline-block; animation: spin 1s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- grille de modules ---------- */
.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.module-card {
  display: block; border: 1px solid var(--line); border-radius: 16px;
  padding: .9rem 1rem; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.module-card:hover { border-color: var(--accent-2); box-shadow: 0 4px 14px rgba(255, 94, 98, .12); }
.module-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.module-promise {
  color: var(--muted); font-size: .82rem; margin: .3rem 0 .5rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.badge {
  font-size: .72rem; font-weight: 700; padding: .15rem .5rem;
  border-radius: 999px; white-space: nowrap;
}
.badge-new { background: var(--accent); color: #fff; }
.badge-date { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: #f4f4f6; color: var(--muted); }
.chip-empty { background: var(--accent-soft); color: var(--accent); }
.chip-a_apprendre { background: var(--accent-soft); color: var(--accent); }
.chip-appris { background: #eaf6ef; color: var(--ok); }
.chip-compris { background: #e7f0fb; color: #2a6bbf; }
.chip-mal_compris { background: #fdf3e4; color: var(--warn); }
.chip-trop_complique { background: #fbeaea; color: var(--bad); }

/* ---------- notions ---------- */
.topics { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.topic {
  display: flex; gap: .8rem; align-items: flex-start;
  border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: 12px; padding: .75rem .9rem; background: #fff;
}
.topic.status-a_apprendre { border-left-color: var(--accent); }
.topic.status-appris { border-left-color: var(--ok); }
.topic.status-compris { border-left-color: #2a6bbf; }
.topic.status-mal_compris { border-left-color: var(--warn); }
.topic.status-trop_complique { border-left-color: var(--bad); }
.topic-main { flex: 1; min-width: 0; }
.topic-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .95rem; }
.topic-detail { margin: .3rem 0 .2rem; font-size: .88rem; color: #3a3a3d; }
.topic-source { font-size: .82rem; }
.status-select {
  border: 1px solid var(--line); border-radius: 9px; padding: .35rem .4rem;
  font-family: inherit; font-size: .8rem; background: #fff; color: var(--ink);
  max-width: 130px;
}

/* ---------- historique ---------- */
.runs { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.run { border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; font-size: .9rem; }
.run-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.run p { margin: .35rem 0 0; }

/* ---------- login ---------- */
.login-body {
  min-height: 100dvh; display: grid; place-items: center;
  background: linear-gradient(160deg, #fff 40%, var(--accent-soft));
  padding: 1rem;
}
.login-card {
  width: 100%; max-width: 330px; text-align: center;
  display: flex; flex-direction: column; gap: .8rem;
  border: 1px solid var(--line); border-radius: 20px; background: #fff;
  padding: 2rem 1.5rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .06);
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
.login-logo img { border-radius: 18px; }
.login-card input {
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem;
  font-size: 1rem; font-family: inherit; text-align: center;
}

@media (max-width: 540px) {
  .maj-head { flex-direction: column; }
  .maj-form { max-width: none; width: 100%; }
}
