/* ==========================================================================
   Portail classe — design glassmorphism orange/rouge
   ========================================================================== */

* { box-sizing: border-box; font-family: 'Poppins', sans-serif; }

:root {
  --bg-start: #FF6B35;
  --bg-end: #C0392B;
  --bg-gradient: linear-gradient(160deg, #FF6B35 0%, #FF6B35 20%, #E8143C 65%, #C0392B 100%);
  --color-on-light-accent: color-mix(in srgb, var(--bg-end) 62%, #111827 38%);
  --color-success: #86efac;
  --color-danger:  #fca5a5;
  --color-muted:   rgba(255,255,255,0.65);
  --color-border:  rgba(255,255,255,0.25);
  --tap: 48px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

html {
  margin: 0; padding: 0;
  font-size: 17px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-start);
  background-image: var(--bg-gradient);
}

/* Fond fixe sur html::before — jamais clippé par overflow du body */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg-start);
  background-image: var(--bg-gradient);
}

body {
  margin: 0; padding: 0;
  height: 100%;
  background: transparent;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.student-page, .teacher-page {
  min-height: 100vh;
  min-height: 100dvh;
  color: white;
  text-shadow: 0 1px 5px rgba(0,0,0,0.45);
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.gradient-colors {
  display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.gradient-colors label {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.85rem; color: var(--color-muted);
}
.gradient-colors input[type="color"] {
  width: 48px; height: 48px; padding: 0; border: none;
  border-radius: var(--radius-sm); cursor: pointer; background: none;
}

/* =========================================================================
   Boutons
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 20px;
  border: none; border-radius: var(--radius-md);
  font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: white; color: var(--color-on-light-accent); font-weight: 700; }
.btn--primary:hover { opacity: 0.9; }
.btn--secondary { background: rgba(255,255,255,0.25); color: white; }
.btn--ghost {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
}
.btn--danger {
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
}
.btn--close {
  background: rgba(255,255,255,0.2); color: white;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
}
.btn--sm { min-height: 36px; padding: 6px 14px; font-size: 0.88rem; }

/* =========================================================================
   Inputs / formulaires
   ========================================================================= */
input[type=text], input[type=password], input[type=color],
select, textarea {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 12px;
  color: white;
  outline: none;
  transition: border-color 0.15s;
  min-height: var(--tap);
}
input[type=color] { padding: 4px; height: var(--tap); }
textarea {
  resize: vertical; min-height: 200px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.55); }
input:focus, select:focus, textarea:focus { border-color: rgba(255,255,255,0.7); }
select option { background: #C0392B; color: white; }
label {
  display: block; font-weight: 600; margin-bottom: 14px;
  color: rgba(255,255,255,0.85);
}
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
.form-error  { color: #fca5a5; margin-top: 10px; min-height: 1.2em; font-weight: 500; }
.form-success { color: #86efac; margin-left: 12px; font-weight: 500; }

/* =========================================================================
   Page de connexion
   ========================================================================= */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.login-container { width: 100%; max-width: 900px; text-align: center; }
.login-title {
  color: white; font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 0 0 8px; font-weight: 700;
}
.login-subtitle { color: rgba(255,255,255,0.85); font-size: 1.1rem; margin: 0 0 30px; }
.login-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.login-card {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-lg);
  padding: 30px 25px;
  text-align: left; color: white;
}
.login-card h2 { margin: 0 0 20px; font-size: 1.3rem; color: white; }
.login-card__emoji { font-size: 3rem; text-align: center; margin-bottom: 10px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* Flux multi-étapes (rôle → prénom → classe) */
.login-step {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  color: white;
  position: relative;
}
.login-back {
  position: absolute; top: 14px; left: 14px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  border-radius: 12px; padding: 8px 14px;
  font-weight: 600; cursor: pointer;
  min-height: 40px;
}
.login-back:active { transform: scale(0.97); }
.login-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; margin: 0 auto; }
.login-form label { text-align: left; }
.login-loading { color: rgba(255,255,255,0.75); padding: 30px; }

.login-role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  max-width: 600px; margin: 10px auto 0;
}
.login-role-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-lg);
  color: white; cursor: pointer;
  padding: 28px 18px;
  min-height: 160px;
  font-family: inherit;
  transition: transform 0.08s ease, background 0.15s;
}
.login-role-card:hover { background: rgba(255,255,255,0.22); }
.login-role-card:active { transform: scale(0.97); }
.login-role-card__emoji { font-size: 3rem; line-height: 1; }
.login-role-card__title { font-size: 1.1rem; font-weight: 700; }

.login-classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-width: 760px;
  margin: 10px auto 0;
}
.login-class-card {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-lg);
  color: white;
  cursor: pointer;
  padding: 22px 16px;
  min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
  transition: transform 0.08s ease, background 0.15s;
}
.login-class-card:hover { background: rgba(255,255,255,0.25); }
.login-class-card:active { transform: scale(0.97); }
.login-class-card__name { font-size: 1.25rem; font-weight: 700; }
.login-class-card__teacher { font-size: 0.92rem; color: rgba(255,255,255,0.8); }

/* =========================================================================
   Page élève
   ========================================================================= */
.student-page { padding-bottom: max(30px, env(safe-area-inset-bottom)); }
.teacher-page { padding-bottom: max(30px, env(safe-area-inset-bottom)); }

.student-header {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.25);
  padding: 16px 24px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  position: relative;
}
.student-header__left { display: flex; align-items: center; gap: 14px; }
.student-emoji { font-size: 2.2rem; }
.student-avatar-link { display: block; text-decoration: none; flex-shrink: 0; }
.student-avatar-mini {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 3px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.student-avatar-mini:hover {
  transform: scale(1.1);
  border-color: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.student-avatar-mini svg { width: 100%; height: 100%; }
.student-hello { font-size: 22px; font-weight: 700; color: white; }
.student-class { font-size: 14px; color: rgba(255,255,255,0.75); }
.student-header .btn--ghost {
  background: white; color: var(--color-on-light-accent); border: none;
  border-radius: 14px; padding: 10px 20px; font-weight: 600;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px; padding: 24px; max-width: 1100px; margin: 0 auto;
}
.stat {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 18px; text-align: center;
}
.stat__value { font-size: 36px; font-weight: 700; color: white; }
.stat__label { color: rgba(255,255,255,0.75); font-size: 13px; }
.stat--bar { text-align: left; }
.stat__percent { margin-top: 6px; font-weight: 700; color: white; }
.progress {
  margin-top: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 999px; overflow: hidden; height: 14px;
}
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, #86efac, white);
  transition: width 0.5s ease; width: 0%;
}

/* ---- Badges élève ---- */
.header-badges {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.header-badges:empty { display: none; }
.header-badges .badge-item { pointer-events: auto; }
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.badge-item img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(255,220,80,0.7));
}
.badge-item__label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-align: center;
}

/* ---- Animation badge débloqué (pack opening) ---- */
#badge-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; overflow: hidden;
}
.bdg-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 42%, #1e0840 0%, #06001a 100%);
}
.bdg-bg::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 15% 25%, rgba(255,255,255,.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 65%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 80% 12%, rgba(255,255,255,.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 78%, rgba(255,255,255,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 8% 58%, rgba(255,255,255,.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 92% 42%, rgba(255,255,255,.35) 0%, transparent 100%),
    radial-gradient(2px 2px at 50% 22%, rgba(255,255,255,.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 85%, rgba(255,255,255,.4) 0%, transparent 100%);
  background-size: 700px 700px;
  animation: bdgStars 25s linear infinite;
}
@keyframes bdgStars { to { background-position: 700px 700px; } }

#badge-pcanvas { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

.bdg-flash { position: absolute; inset: 0; background: white; opacity: 0; pointer-events: none; z-index: 20; }
.bdg-flash.bdg-bang { animation: bdgFlash .5s ease-out forwards; }
@keyframes bdgFlash { 0%{opacity:1} 100%{opacity:0} }

.bdg-wave {
  position: absolute; top: 50%; left: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  border: 4px solid rgba(255,220,60,.9);
  transform: translate(-50%,-50%) scale(0); opacity: 0;
  pointer-events: none; z-index: 15;
}
.bdg-wave.bdg-go { animation: bdgWave .9s ease-out forwards; }
#badge-w2.bdg-go { animation-delay:.12s; border-color: rgba(255,100,50,.8); }
#badge-w3.bdg-go { animation-delay:.24s; border-color: rgba(180,80,255,.7); }
@keyframes bdgWave {
  0%   { transform:translate(-50%,-50%) scale(0); opacity:1; border-width:4px; }
  100% { transform:translate(-50%,-50%) scale(38); opacity:0; border-width:1px; }
}

#badge-phase-mystery {
  position: relative; z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.bdg-mystery-label {
  color: rgba(255,255,255,.55); font-size: 13px; letter-spacing: 3px;
  text-transform: uppercase; animation: bdgBlink 2s ease-in-out infinite;
}
@keyframes bdgBlink { 0%,100%{opacity:.35} 50%{opacity:1} }

.bdg-mbox {
  width: 140px; height: 140px; border-radius: 26px; cursor: pointer;
  background: radial-gradient(circle at 36% 30%, #b060f0, #18002e);
  display: flex; align-items: center; justify-content: center; font-size: 66px;
  box-shadow: 0 0 0 2px rgba(180,100,255,.5), 0 0 40px rgba(160,80,240,.9),
              0 0 100px rgba(140,60,210,.5), inset 0 1px 0 rgba(255,255,255,.12);
  animation: bdgBoxFloat 3s ease-in-out infinite, bdgBoxGlow 2s ease-in-out infinite alternate;
  user-select: none; position: relative;
}
.bdg-mbox::before, .bdg-mbox::after {
  content: ''; position: absolute; width: 22px; height: 22px;
  border-color: rgba(255,220,60,.65); border-style: solid; border-radius: 3px;
}
.bdg-mbox::before { top: 9px; left: 9px;   border-width: 2.5px 0 0 2.5px; }
.bdg-mbox::after  { bottom: 9px; right: 9px; border-width: 0 2.5px 2.5px 0; }
@keyframes bdgBoxFloat {
  0%,100%{ transform:translateY(0) rotate(0); }
  35%    { transform:translateY(-15px) rotate(-2deg); }
  65%    { transform:translateY(-10px) rotate(2deg); }
}
@keyframes bdgBoxGlow {
  from { box-shadow:0 0 0 2px rgba(180,100,255,.5),0 0 45px rgba(160,80,240,.9),0 0 100px rgba(140,60,210,.4); }
  to   { box-shadow:0 0 0 2px rgba(220,140,255,.8),0 0 75px rgba(200,110,255,1),0 0 160px rgba(160,80,240,.6); }
}
.bdg-mbox.bdg-shake { animation: bdgShake .55s cubic-bezier(.36,.07,.19,.97) both !important; }
@keyframes bdgShake {
  0%,100%{ transform:translate(0,0) rotate(0); }
  10%{ transform:translate(-11px,0) rotate(-7deg); }
  20%{ transform:translate(13px,0) rotate(7deg); }
  30%{ transform:translate(-13px,-3px) rotate(-5deg); }
  40%{ transform:translate(13px,3px) rotate(5deg); }
  50%{ transform:translate(-9px,0) rotate(-3deg); }
  60%{ transform:translate(9px,0) rotate(3deg); }
  80%{ transform:translate(-4px,0) rotate(-1deg); }
}
.bdg-tap-label { color: rgba(255,255,255,.45); font-size: 13px; animation: bdgBlink 1.5s ease-in-out infinite; }

#badge-phase-reveal {
  position: relative; z-index: 30;
  display: flex; flex-direction: column; align-items: center;
}
.bdg-scene { perspective: 900px; position: relative; z-index: 5; }
.bdg-card {
  width: 170px; height: 170px; position: relative;
  animation: bdgReveal 1.15s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes bdgReveal {
  0%  { transform:scale(0) rotateY(-210deg) rotateX(30deg); opacity:0; filter:brightness(5); }
  50% { transform:scale(1.28) rotateY(22deg) rotateX(-5deg); opacity:1; filter:brightness(1.6); }
  72% { transform:scale(0.92) rotateY(-8deg); filter:brightness(1.1); }
  86% { transform:scale(1.07) rotateY(4deg); }
  100%{ transform:scale(1) rotateY(0) rotateX(0); filter:brightness(1); }
}
.bdg-card img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 0 20px var(--bdg-glow, rgba(255,210,60,.9)))
          drop-shadow(0 0 55px var(--bdg-glow2, rgba(255,160,0,.55)));
  animation: bdgFloat 3.2s ease-in-out 1.15s infinite;
}
@keyframes bdgFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-11px)} }
.bdg-gleam {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden; pointer-events: none;
}
.bdg-gleam::after {
  content: ''; position: absolute; top: 0; left: -100%; width: 55%; height: 100%;
  background: linear-gradient(108deg, transparent 38%, rgba(255,255,255,.6) 50%, transparent 62%);
  animation: bdgGleam 2.6s ease-in-out 1.1s infinite;
}
@keyframes bdgGleam {
  0%,38%{left:-100%;opacity:0} 43%{opacity:1} 68%{left:150%;opacity:0} 100%{left:150%;opacity:0}
}
.bdg-orbit {
  position: absolute; top:50%; left:50%; width:0; height:0;
  animation: bdgOrbitSpin var(--spd) linear infinite var(--delay);
}
@keyframes bdgOrbitSpin { to { transform:rotate(360deg); } }
.bdg-orbit-gem {
  position: absolute;
  top: calc(var(--r) * -1); left: calc(var(--sz) * -.5);
  width: var(--sz); height: var(--sz);
  background: var(--col); border-radius: 2px; transform: rotate(45deg);
  box-shadow: 0 0 8px var(--col), 0 0 18px var(--col);
  animation: bdgGemPulse 1.1s ease-in-out infinite alternate;
}
@keyframes bdgGemPulse {
  from { transform:rotate(45deg) scale(.65); opacity:.55; }
  to   { transform:rotate(45deg) scale(1.35); opacity:1; }
}
.bdg-title {
  font-size: 32px; font-weight: 900; letter-spacing: 3px; text-transform: uppercase;
  color: var(--bdg-text-color, #FFD700);
  text-shadow: 0 0 14px var(--bdg-glow, rgba(255,180,0,.95)),
               0 0 45px var(--bdg-glow2, rgba(255,140,0,.65)),
               0 3px 0 rgba(0,0,0,.45);
  margin-top: 22px; opacity: 0; transform: translateY(-44px) scale(.8);
  animation: bdgTitleSlam .55s cubic-bezier(0.175,0.885,0.32,1.4) .8s forwards;
}
@keyframes bdgTitleSlam { to { opacity:1; transform:translateY(0) scale(1); } }
.bdg-title.bdg-rainbow {
  background: linear-gradient(90deg,#FFD700,#FF6B35,#FF3CAC,#784BA0,#2B86C5,#00C9A7,#A8FF3E,#FFD700);
  background-size: 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  animation: bdgTitleSlam .55s cubic-bezier(0.175,0.885,0.32,1.4) .8s forwards,
             bdgRainbow 3s linear 1.35s infinite;
}
@keyframes bdgRainbow { to { background-position: 300% center; } }
.bdg-sub {
  font-size: 15px; color: rgba(255,255,255,.8); margin-top: 10px; text-align: center;
  opacity: 0; animation: bdgFadeIn .5s ease 1.25s forwards;
}
@keyframes bdgFadeIn { to { opacity:1; } }
.bdg-btn {
  margin-top: 28px;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  color: #180800; border: none; border-radius: 999px;
  padding: 15px 46px; font-family: 'Poppins', sans-serif;
  font-size: 17px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 24px rgba(255,180,0,.55);
  opacity: 0; transform: translateY(24px);
  animation: bdgBtnRise .45s ease 1.65s forwards, bdgBtnPulse 2s ease-in-out 2.3s infinite;
  transition: transform .15s;
}
@keyframes bdgBtnRise { to { opacity:1; transform:translateY(0); } }
@keyframes bdgBtnPulse {
  0%,100%{ box-shadow:0 4px 24px rgba(255,180,0,.55),0 0 0 0 rgba(255,200,0,.3); }
  50%    { box-shadow:0 4px 24px rgba(255,180,0,.55),0 0 0 16px rgba(255,200,0,0); }
}
.bdg-btn:hover { transform: translateY(-3px) scale(1.04); }

.exercises-container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.subject-section { margin-bottom: 28px; }
.subject-title {
  display: flex; align-items: center; gap: 10px;
  margin: 32px 0 12px; font-size: 20px; font-weight: 700; color: white;
}
.subject-title__dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }

.subject-progress {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.subject-progress__bar {
  flex: 1; min-width: 60px;
  background: rgba(255,255,255,0.2);
  border-radius: 999px; overflow: hidden; height: 8px;
}
.subject-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, #86efac, white);
  border-radius: 999px;
  transition: width 0.5s ease; width: 0%;
}
.subject-progress__pct {
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap; min-width: 36px; text-align: right;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.exercise-card {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.exercise-card--mastered > *:not(.exercise-card__check) { opacity: 0.5; }
.exercise-card__check {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 1;
}
.exercise-card__check svg {
  width: 68px; height: 68px;
  filter: drop-shadow(0 2px 8px rgba(90,160,110,0.3));
}
.exercise-card:hover, .exercise-card:focus-visible {
  transform: translateY(-4px);
  background: rgba(255,255,255,0.25);
}
.exercise-card:active { transform: scale(0.98); }
.exercise-card--done { border-color: rgba(134,239,172,0.55); }
.exercise-card__top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
}
.exercise-card__emoji { font-size: 40px; margin-bottom: 4px; }
.exercise-card__score {
  background: rgba(255,255,255,0.9);
  padding: 4px 10px; border-radius: 999px;
  font-weight: 700; font-size: 0.88rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.exercise-card__name  { margin: 0; font-size: 16px; font-weight: 600; color: white; }
.exercise-card__desc  { color: rgba(255,255,255,0.75); font-size: 13px; line-height: 1.4; margin: 0; }
.exercise-card__meta  { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-block; padding: 4px 10px;
  border-radius: 999px; color: white;
  font-size: 0.78rem; font-weight: 700;
}
.badge--subject {
  background: rgba(255,255,255,0.25); color: white;
  border-radius: 20px; padding: 4px 10px; font-size: 12px;
}
.badge--niveau {
  background: rgba(0,0,0,0.15); color: rgba(255,255,255,0.85);
  border-radius: 20px; padding: 4px 10px;
}
.loading, .empty { text-align: center; color: rgba(255,255,255,0.7); padding: 40px; }

/* =========================================================================
   Modale exercice (élève) — plein écran
   ========================================================================= */
.exercise-modal {
  position: fixed; inset: 0; background: white;
  z-index: 100; display: flex; flex-direction: column;
}
.exercise-modal[hidden] { display: none; }
.exercise-modal__bar {
  background: var(--bar-bg, rgba(192,57,43,0.95));
  backdrop-filter: blur(10px);
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.exercise-modal__bar .btn--close {
  color: white;
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
}
.exercise-modal__title {
  font-weight: 700; font-size: 1.05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.exercise-modal__frame { flex: 1; border: none; width: 100%; background: white; }

/* =========================================================================
   Page enseignant
   ========================================================================= */
.teacher-header {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.25);
  padding: 16px 24px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.teacher-header h1 { margin: 0; font-size: 1.3rem; font-weight: 700; color: white; }
.teacher-header .btn--ghost {
  background: white; color: var(--color-on-light-accent); border: none;
  border-radius: 14px; padding: 10px 20px; font-weight: 600;
}

.tabs {
  display: flex; gap: 6px;
  padding: 6px;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  margin: 16px 24px;
  width: fit-content;
  max-width: calc(100% - 48px);
  overflow-x: auto;
}
.tab {
  background: transparent; border: none; border-radius: 12px;
  padding: 10px 20px; cursor: pointer;
  font-weight: 600; color: rgba(255,255,255,0.8);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab--active { background: white; color: var(--color-on-light-accent); font-weight: 700; }

.tab-content { display: none; padding: 0 24px 24px; max-width: 1300px; margin: 0 auto; }
.tab-content--active { display: block; }

.actions-bar { margin-bottom: 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.actions-bar > * { flex: 1; min-width: 0; }

.sort-control {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: var(--tap);
  background: rgba(255,255,255,0.2);
}
.sort-control__label {
  display: flex;
  align-items: center;
  padding: 10px 14px 10px 16px;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  gap: 6px;
  user-select: none;
}
.sort-control__select {
  flex: 1;
  min-width: 0;
  width: 0;
  background: white;
  border: none;
  border-radius: 0;
  margin: 0;
  outline: none;
  color: var(--color-on-light-accent);
  padding: 10px 14px;
  font-family: Poppins, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sort-control__select:hover { opacity: 0.9; }
.btn--sort {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  min-height: 40px; padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; font-family: inherit; font-size: inherit;
  transition: background 0.15s, color 0.15s;
}
.btn--sort--active { background: white; color: var(--color-on-light-accent); }

.score-chip { text-shadow: none; }

.exercise-search-wrapper { margin-bottom: 14px; }

/* TABLEAU PROGRESSION */
.table-wrapper {
  overflow-x: auto;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.progress-table { border-collapse: collapse; width: 100%; min-width: 500px; }
.progress-table th, .progress-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center; white-space: nowrap;
}
.progress-table th {
  color: rgba(255,255,255,0.6);
  font-size: 13px; text-transform: uppercase; font-weight: 600;
  position: sticky; top: 0;
  background: rgba(255,255,255,0.05);
}
.progress-table td { color: white; }
.progress-table th:first-child, .progress-table td:first-child {
  text-align: left; position: sticky; left: 0;
  background: rgba(255,255,255,0.05);
  font-weight: 600; z-index: 1;
  padding: 10px 15px 10px 20px;
  width: 0.1%;
}

.progress-table th:first-child { z-index: 2; background: rgba(255,255,255,0.08); }
.cell-score { font-weight: 600; color: white; }
.cell-empty { color: rgba(255,255,255,0.4); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; }

/* DEUX COLONNES */
.two-cols { display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: 24px; }
@media (max-width: 800px) { .two-cols { grid-template-columns: 1fr; } }

.col {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 18px;
}
.section-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.section-header h2 { margin: 0; font-size: 1.2rem; color: white; }

.subjects-list, .exercises-list-teacher, .students-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.subject-item, .exercise-item, .student-item {
  background: rgba(0,0,0,0.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
}
.subject-item__color { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; }
.subject-item__name, .exercise-item__main { flex: 1; min-width: 0; color: white; font-weight: 600; }
.exercise-item__main strong {
  display: block; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: white;
}
.exercise-item__main small { color: rgba(255,255,255,0.7); }
.exercise-item--hidden { opacity: 0.55; }
.item-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.presence-dot {
  display: inline-block; vertical-align: middle;
  width: 10px; height: 10px; border-radius: 50%;
  margin-right: 7px;
}
.presence-dot--online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.8); }
.presence-dot--offline { background: #ef4444; }
.icon-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn--danger:hover { background: rgba(252,165,165,0.3); }

/* RÉGLAGES */
.settings-card {
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  padding: 22px; margin-bottom: 20px; max-width: 700px;
}
.settings-card h2 { margin: 0 0 14px; font-size: 1.2rem; color: white; }
.settings-card form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings-card form input { flex: 1; min-width: 200px; }
.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row input[type="checkbox"] { width: 44px; height: 24px; appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.2); border-radius: 12px; position: relative; cursor: pointer;
  transition: background 0.2s; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.3); }
.toggle-row input[type="checkbox"]:checked { background: #4ade80; border-color: #4ade80; }
.toggle-row input[type="checkbox"]::after { content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.toggle-label-text { color: white; font-size: 1rem; font-weight: 500; }
.settings-hint { margin: 10px 0 0; font-size: 0.85rem; color: rgba(255,255,255,0.65); line-height: 1.5; }

/* APERÇU ÉLÈVE DANS L'ONGLET EXERCICES */
.student-preview-section {
  margin: 24px 0 0;
  background: rgba(0,0,0,0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  overflow: hidden;
}

.student-preview-section__header {
  min-height: 54px;
  padding: 10px 14px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  color: white;
  font-weight: 700;
}

.student-preview-frame {
  display: block;
  width: 100%;
  height: min(720px, 72vh);
  min-height: 420px;
  border: 0;
  background-color: var(--bg-start);
  background-image: var(--bg-gradient);
}

/* =========================================================================
   Modales (enseignant)
   ========================================================================= */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 200;
  animation: fadeIn 0.15s ease;
}
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal__content {
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.modal__content--large { max-width: 720px; }
.modal__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__header h3 { margin: 0; font-size: 20px; font-weight: 700; color: white; }
.modal__header .btn--close { background: rgba(255,255,255,0.15); color: white; }
.form { padding: 20px 24px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }
.form-help {
  background: rgba(255,255,255,0.1);
  border-left: 4px solid rgba(255,255,255,0.5);
  padding: 10px 14px; border-radius: 8px;
  font-size: 0.88rem; color: rgba(255,255,255,0.8);
  margin: 6px 0 14px;
}
.form-help code {
  background: rgba(0,0,0,0.2); padding: 1px 5px;
  border-radius: 4px; font-size: 0.82rem; color: white;
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.checkbox-label {
  display: flex !important; align-items: center; gap: 10px;
  font-weight: 500; color: rgba(255,255,255,0.85);
}
.checkbox-label input { width: auto; min-height: auto; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 767px) {
  .two-cols { grid-template-columns: 1fr; }
  .two-cols .col:first-child { display: none; }

  /* Header enseignant : éviter les retours à la ligne */
  .teacher-header { padding: max(12px, env(safe-area-inset-top)) 14px 12px; gap: 8px; }
  .teacher-header h1 { font-size: 1rem; }
  .teacher-header .btn--ghost { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; flex-shrink: 0; }

  /* Exercices : empêche le débordement hors de la carte */
  #tab-exercises .col { overflow-x: hidden; }
  #tab-exercises .section-header { flex-wrap: wrap; gap: 6px; }

  /* Progression : actions-bar sur 2 lignes lisibles */
  .actions-bar { gap: 8px; }
  .actions-bar .sort-control { flex: 1 1 calc(50% - 8px); }
  .sort-control__label  { font-size: 0.78rem; padding: 8px 8px 8px 10px; }
  .sort-control__select { font-size: 0.78rem; padding: 8px 6px; }
  .actions-bar .btn--primary { flex: 1 1 calc(33% - 8px); white-space: nowrap; font-size: 0.75rem; padding: 10px 6px; overflow: hidden; }
}

/* Login : éviter la superposition bouton Retour / titre sur iPhone */
@media (max-width: 480px) {
  .login-step { padding-top: 70px; }
}

@media (max-width: 500px) {
  .student-header { padding: 14px; }
  .student-hello  { font-size: 18px; }
  .stats-bar      { padding: 14px; }
  .exercises-container { padding: 0 14px; }
  .tab  { padding: 8px 12px; font-size: 0.88rem; }
  .tabs { margin: 12px 14px; }
  .tab-content    { padding: 0 14px 14px; }
}

/* ==========================================================================
   Onglet Enseignants (superadmin)
   ========================================================================== */
.teacher-name-badge {
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  margin-left: 8px;
}
.teachers-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.teacher-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 12px 14px;
}
.teacher-item__main { flex: 1; min-width: 0; }
.teacher-item__name {
  font-weight: 700;
  color: white;
  font-size: 1rem;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.teacher-item__badge {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.teacher-item__meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.78);
}
.teacher-item__nocls { font-style: italic; opacity: 0.7; }

/* ── Crédits bas de page (login) ── */
.site-credits {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  padding: 10px 20px max(10px, env(safe-area-inset-bottom));
  color: rgba(255,255,255,0.45);
  font-size: 0.65rem;
  line-height: 1.6;
  pointer-events: none;
}
.credits-title {
  margin: 0 0 4px;
  font-size: 0.7rem;
  letter-spacing: 0.3px;
}
.credits-title strong {
  color: rgba(255,255,255,0.65);
  font-weight: 600;
}
.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 14px;
}
.credits-list li {
  white-space: nowrap;
}
