:root {
  --bg: #eef3fb;
  --out: #d9e3f5;
  --card: #fff;
  --ink: #0f1e45;
  --mut: #5a6786;
  --line: #e2e8f4;
  --pri: #2f6bff;
  --ok: #0a7a52;
  --okb: #ddf7ec;
  --wr: #9a5200;
  --wrb: #ffebcf;
  --bd: #b42318;
  --bdb: #fde4e1;
  --vi: #7b3ff2;
  --sh: 0 1px 2px rgba(16, 32, 79, 0.06), 0 8px 22px rgba(16, 32, 79, 0.07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1230;
    --out: #050b22;
    --card: #111c44;
    --ink: #eaf0ff;
    --mut: #9dabd2;
    --line: #22305f;
    --pri: #6b96ff;
    --ok: #4ade9f;
    --okb: rgba(74, 222, 159, 0.14);
    --wr: #fbbf5b;
    --wrb: rgba(251, 191, 91, 0.14);
    --bd: #ff8a80;
    --bdb: rgba(255, 138, 128, 0.14);
    --vi: #a78bfa;
    --sh: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1230;
  --out: #050b22;
  --card: #111c44;
  --ink: #eaf0ff;
  --mut: #9dabd2;
  --line: #22305f;
  --pri: #6b96ff;
  --ok: #4ade9f;
  --okb: rgba(74, 222, 159, 0.14);
  --wr: #fbbf5b;
  --wrb: rgba(251, 191, 91, 0.14);
  --bd: #ff8a80;
  --bdb: rgba(255, 138, 128, 0.14);
  --vi: #a78bfa;
  --sh: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
body {
  margin: 0;
  background: var(--out);
  color: var(--ink);
  font:
    400 14px Poppins,
    system-ui,
    sans-serif;
}
.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: clip;
}
@media (min-width: 520px) {
  .phone {
    margin: 24px auto;
    min-height: calc(100vh - 48px);
    border-radius: 32px;
    box-shadow: 0 30px 80px rgba(5, 12, 40, 0.3);
  }
}
.hd {
  background: linear-gradient(135deg, #2b1465, #7b3ff2 120%);
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 26px;
  border-radius: 0 0 28px 28px;
}
.top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top img {
  width: 38px;
}
.top b {
  font-size: 16px;
  display: block;
}
.top small {
  color: #d8cbf7;
}
.ib {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.hd h1 {
  margin: 18px 0 2px;
  font-size: 22px;
  font-weight: 700;
}
.hd p {
  margin: 0 0 14px;
  color: #d8cbf7;
}
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffd166, #ff8a65);
  color: #2b1b00;
  font-weight: 800;
  font-size: 22px;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}
.hd .row-av {
  display: flex;
  align-items: center;
  gap: 14px;
}
.badge-rang {
  height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.scr {
  flex: 1;
  padding: 18px 16px calc(88px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  animation: in 0.3s ease both;
}
@keyframes in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--sh);
}
.g2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
}
.big {
  font-size: 28px;
  font-weight: 800;
  margin: 4px 0;
}
h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
}
.ok {
  background: var(--okb);
  color: var(--ok);
}
.wr {
  background: var(--wrb);
  color: var(--wr);
}
.bd {
  background: var(--bdb);
  color: var(--bd);
}
.btn {
  height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--pri);
  color: #fff;
  font:
    600 14px Poppins,
    sans-serif;
  cursor: pointer;
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.btn.g {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.s {
  height: 40px;
  width: auto;
  padding: 0 14px;
  font-size: 13px;
}
.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7b3ff2, #00c2e0);
  border-radius: 99px;
  transition: width 0.7s;
}
.li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  width: 100%;
  background: none;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.li:first-of-type {
  border-top: 0;
}
.li div {
  flex: 1;
  min-width: 0;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pri);
  margin-top: 6px;
  flex: none;
}
.dot.r {
  background: transparent;
  border: 2px solid var(--line);
}
.mat-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.mat-row:first-of-type {
  border-top: 0;
}
.mat-nom {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}
.mat-nom small {
  display: block;
  color: var(--mut);
  font-weight: 400;
  font-size: 11px;
}
.mat-note {
  width: 58px;
  text-align: center;
  font-weight: 800;
  font-size: 17px;
}
.mat-note small {
  display: block;
  font-size: 9px;
  color: var(--mut);
  font-weight: 600;
}
.nv {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--card) !important;
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(5, 12, 40, 0.08);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  flex-shrink: 0;
}
.nv button {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  border: 0;
  background: none;
  color: var(--mut);
  font:
    500 10.5px Poppins,
    sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}
.nv button.on {
  color: var(--pri);
  font-weight: 700;
}
.nv em {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  background: #e5484d;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.in {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: var(--card);
  color: var(--ink);
  font:
    500 14px Poppins,
    sans-serif;
}
.in:focus {
  outline: 2px solid var(--pri);
  outline-offset: 1px;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  padding: 0 2px;
}
.bars > div {
  flex: 1;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--mut);
}
.bars i {
  display: block;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #00c2e0, #7b3ff2);
  margin-bottom: 4px;
  transition: height 0.8s;
}
.pct-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.pct-row:first-of-type {
  border-top: 0;
}
.pct-row .pc {
  min-width: 44px;
  text-align: right;
  font-weight: 800;
}
.lg {
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  justify-content: center;
  text-align: center;
}
.lg img {
  width: 72px;
  margin: 0 auto;
}
.lg h1 {
  margin: 6px 0 0;
  font-size: 24px;
}
.lg p {
  margin: 0;
  color: var(--mut);
}
.lk {
  background: none;
  border: 0;
  color: var(--pri);
  font:
    600 13px Poppins,
    sans-serif;
  cursor: pointer;
  min-height: 44px;
}
.dz {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.dz:first-of-type {
  border-top: 0;
}
.dz-date {
  width: 46px;
  flex: none;
  text-align: center;
  background: rgba(123, 63, 242, 0.1);
  border-radius: 12px;
  padding: 7px 0;
}
.dz-date b {
  display: block;
  font-size: 15px;
  line-height: 1.1;
}
.dz-date small {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--mut);
  font-weight: 700;
}
.info {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.info:first-of-type {
  border-top: 0;
}
.info .k {
  color: var(--mut);
  font-size: 12px;
  min-width: 120px;
}
.info .v {
  font-weight: 600;
  text-align: right;
  flex: 1;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: #10204f;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  opacity: 0;
  transition: 0.3s;
  pointer-events: none;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- MENU / NAV — lisibilite dans les deux themes ---------- */
.nv button { color: var(--mut); }
.nv button.on { color: var(--pri); }
.nv button span, .nv button small { color: inherit; }
.lbl { color: var(--mut) !important; }
.card h2, .card h3, .card .big { color: var(--ink) !important; }

/* ---------- AUCUN DEBORDEMENT HORIZONTAL ---------- */
html, body { overflow-x: hidden; }
.card, .in, table { max-width: 100%; }
.sc, .tableau { overflow-x: auto; }

/* ============================================================
   ECRAN DE CONNEXION : couleurs forcees
   ============================================================ */
html:not(.dark) .lg h1 { color: #0F1E45 !important; }
html:not(.dark) .lg p  { color: #5A6786 !important; }
html.dark .lg h1 { color: #EAF0FF !important; }
html.dark .lg p  { color: #9DABD2 !important; }
.lg .lbl { color: var(--mut) !important; }

/* ============================================================
   ESPACE (parent / eleve) : couleurs du theme, jamais de texte clair
   sur fond clair. On s'appuie sur les variables --ink / --mut / --card.
   ============================================================ */
body { background: var(--out) !important; color: var(--ink) !important; }
.phone { background: var(--bg) !important; color: var(--ink) !important; }
.phone h1, .phone h2, .phone h3, .phone .big { color: var(--ink) !important; }
.phone p, .phone li, .phone label, .phone small { color: var(var(--mut)) !important; }
.phone .card { background: var(--card) !important; color: var(--ink) !important; }
.phone .lbl { color: var(--mut) !important; }
.phone .in { background: var(--card) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.phone .btn:not(.g) { color: #fff !important; }
.phone .btn.g { background: var(--card) !important; color: var(--ink) !important; }
.phone .nv button { color: var(--mut) !important; }
.phone .nv button.on { color: var(--pri) !important; }
.phone .hd, .phone .hd * { color: #fff !important; }
.phone .hd p, .phone .hd small { color: #C3D0F5 !important; }

/* Bouton retour élégant et centré par rapport au cadre téléphone */
.ds-back-home {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #2b1465;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform .2s ease;
}
.ds-back-home:hover { transform: scale(1.08); }
@media(min-width: 580px) {
  .ds-back-home {
    top: 24px;
    left: calc(50% - 240px - 58px);
  }
}

/* ---------- DEVOIRS INTERACTIFS (cocher fait / terminé) ---------- */
.dz {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  margin-top: 8px;
  transition: all .2s ease;
}
.dz:hover {
  border-color: var(--pri);
  transform: translateY(-1px);
}
.dz-date {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(47,107,255,.14), rgba(123,63,242,.12));
  color: var(--pri);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  flex-shrink: 0;
}
.dz-date b { font-size: 16px; font-weight: 800; }
.dz-date small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; }
.dz-chk {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), background .2s, border-color .2s;
}
.dz-chk:hover {
  transform: scale(1.15);
  border-color: var(--ok);
}
.dz-chk.on {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  box-shadow: 0 4px 12px rgba(10,122,82,.35);
}
.dz-chk.on svg { stroke: #fff; }
.dz.fait {
  background: rgba(10,122,82,.04);
  border-color: rgba(10,122,82,.2);
}
.dz.fait b {
  text-decoration: line-through;
  opacity: .75;
}

@keyframes ds-spin { to { transform: rotate(360deg); } }
