* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
  background: #f4f5fb; color: #111827; font-size: 15px; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: #6b7280; }
.small { font-size: 12.5px; }
button { font-family: inherit; cursor: pointer; }
.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 12px; padding: 11px 13px; font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.loader { width: 30px; height: 30px; border: 3px solid #e5e7eb; border-top-color: #6366f1; border-radius: 50%; animation: spin .8s linear infinite; margin: 26px auto 10px; }
.loading-text { text-align: center; color: #6b7280; font-size: 14px; }

/* ---------- Connexion ---------- */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%); padding: 22px; }
.login-card { background: #fff; border-radius: 24px; padding: 32px 24px; width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 24px 60px rgba(76,29,149,.35); animation: fade .4s ease; }
.login-card .logo { width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 20px;
  background: linear-gradient(150deg,#4f46e5,#7c3aed); display: flex; align-items: center; justify-content: center; font-size: 38px;
  box-shadow: 0 8px 20px rgba(79,70,229,.4); }
.login-card h1 { margin: 10px 0 4px; font-size: 23px; font-weight: 800; letter-spacing: -.3px; }
.login-card input { width: 100%; padding: 15px; margin-top: 12px; border: 1.5px solid #e5e7eb; border-radius: 14px; font-size: 16px; background: #f9fafb; }
.login-card input:focus { outline: none; border-color: #6366f1; background: #fff; }
.primary { width: 100%; margin-top: 18px; padding: 15px; border: 0; border-radius: 14px;
  background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 18px rgba(79,70,229,.35); }
.primary:active { transform: scale(.985); }
.primary:disabled { opacity: .55; }

/* ---------- App ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 16px; display: flex; align-items: center; justify-content: space-between;
  border-radius: 0 0 22px 22px; box-shadow: 0 6px 18px rgba(79,70,229,.25); }
.topbar #title { font-weight: 800; font-size: 19px; letter-spacing: -.2px; }
.topbar .link { background: rgba(255,255,255,.16); border: 0; color: #fff; font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 20px; }
#content { flex: 1; overflow-y: auto; padding: 16px 16px 96px; -webkit-overflow-scrolling: touch; }
#content > * { animation: fade .25s ease; }

/* Barre d'onglets */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px); border-top: 1px solid #eceef3; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tab { flex: 1; background: none; border: 0; padding: 10px 0 11px; font-size: 21px; color: #9aa1ad;
  display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { color: #4f46e5; }
.tab.active::before { content: ''; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 3px; background: #4f46e5; }

/* ---------- EDT ---------- */
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.weeknav .arrow { width: 42px; height: 42px; border: 0; border-radius: 13px; background: #fff; font-size: 20px; color: #4f46e5; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.weeknav .center { flex: 1; text-align: center; }
.weeknav .center .lbl { font-weight: 700; font-size: 14px; }
.weeknav .center .today-btn { display: inline-block; margin-top: 2px; font-size: 11.5px; color: #6366f1; font-weight: 600; background: none; border: 0; }
.day { margin-bottom: 18px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px; }
.day-head .dow { font-weight: 800; font-size: 15px; text-transform: capitalize; }
.day-head .dnum { font-size: 12px; color: #9aa1ad; font-weight: 600; }
.day.today .day-head .dow { color: #6d28d9; }
.day.today .day-head::after { content: 'aujourd’hui'; font-size: 10px; font-weight: 700; color: #fff; background: #7c3aed; padding: 2px 8px; border-radius: 20px; }
.evt { display: flex; gap: 12px; background: #fff; border-radius: 16px; padding: 13px 14px; margin-bottom: 9px; box-shadow: 0 2px 8px rgba(17,24,39,.05); }
.evt .bar { width: 4px; border-radius: 4px; flex: 0 0 4px; background: #7c3aed; }
.evt .time { flex: 0 0 52px; text-align: center; }
.evt .time .s { font-weight: 800; font-size: 14px; color: #111827; }
.evt .time .e { font-size: 11px; color: #9aa1ad; }
.evt .body { flex: 1; min-width: 0; }
.evt .body .h { font-weight: 700; font-size: 14.5px; line-height: 1.25; }
.evt .body .m { font-size: 12px; color: #6b7280; margin-top: 3px; }
.empty { text-align: center; padding: 50px 24px; }
.empty .ico { font-size: 46px; }
.empty .t { font-weight: 700; margin-top: 10px; }
.empty .s { color: #9aa1ad; font-size: 13px; margin-top: 4px; }

/* ---------- Boutons ---------- */
.btn { display: block; width: 100%; text-align: center; background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff; border: 0;
  border-radius: 15px; padding: 15px; font-size: 15.5px; font-weight: 700; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.btn:active { transform: scale(.99); }

/* ---------- Fiches ---------- */
.upload { border: 2px dashed #c7cbf3; background: #fff; border-radius: 18px; padding: 26px 18px; text-align: center; margin: 6px 0 14px; }
.upload .ico { font-size: 40px; }
.upload .t { font-weight: 700; margin-top: 6px; }
.fiche { animation: fade .3s ease; }
.fiche h2 { font-size: 20px; margin: 4px 0 2px; letter-spacing: -.3px; }
.fiche .callout { background: linear-gradient(135deg,#eef2ff,#f5f3ff); border: 1px solid #ddd6fe; border-radius: 14px; padding: 13px 14px; margin: 12px 0; }
.fiche .callout b { color: #4338ca; }
.fiche .sec { background: #fff; border-radius: 16px; padding: 14px; margin: 11px 0; box-shadow: 0 2px 8px rgba(17,24,39,.05); }
.fiche .sec h3 { margin: 0 0 7px; color: #4338ca; font-size: 16px; }
.fiche .enbref { background: #eef2ff; border-radius: 10px; padding: 8px 11px; font-size: 13px; color: #3730a3; margin-bottom: 9px; }
.fiche .def { background: #faf5ff; border-left: 3px solid #a78bfa; border-radius: 8px; padding: 8px 11px; margin: 7px 0; font-size: 14px; }
.fiche .term { font-weight: 700; color: #6d28d9; }
.fiche .ex { background: #ecfeff; border-left: 3px solid #06b6d4; border-radius: 8px; padding: 8px 11px; margin: 7px 0; font-size: 14px; }
.fiche .tip { background: #fffbeb; border-left: 3px solid #f59e0b; border-radius: 8px; padding: 8px 11px; margin: 7px 0; font-size: 14px; }
.fiche .formula { background: #f3f4f6; border-radius: 8px; padding: 8px 11px; margin: 7px 0; font-family: ui-monospace, monospace; text-align: center; }
.fiche p { font-size: 14px; line-height: 1.55; margin: 7px 0; }
.fiche ul { margin: 7px 0; padding-left: 20px; }
.fiche li { margin: 4px 0; font-size: 14px; }
.fiche .quiz { background: linear-gradient(135deg,#fffbeb,#fef9c3); border: 1px solid #fde68a; border-radius: 16px; padding: 14px; margin: 11px 0; }
.fiche .quiz h3 { color: #b45309; margin: 0 0 6px; }
.fiche .q { font-weight: 600; font-size: 14px; margin-top: 9px; }
.fiche .a { color: #4b5563; font-size: 13px; margin-top: 2px; }

/* ---------- Devoirs ---------- */
.addcard { background: #fff; border-radius: 18px; padding: 14px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(17,24,39,.05); }
.addcard input { width: 100%; padding: 13px; margin-bottom: 9px; border: 1.5px solid #e5e7eb; border-radius: 12px; font-size: 16px; background: #f9fafb; }
.addcard input:focus { outline: none; border-color: #6366f1; background: #fff; }
.dev { background: #fff; border-radius: 15px; padding: 13px; margin-bottom: 9px; display: flex; align-items: center; gap: 12px; box-shadow: 0 2px 8px rgba(17,24,39,.05); }
.dev .check { width: 26px; height: 26px; border-radius: 9px; border: 2px solid #c7cbf3; flex: 0 0 26px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; }
.dev.done .check { background: #22c55e; border-color: #22c55e; }
.dev .t { font-weight: 600; font-size: 14.5px; }
.dev.done .t { text-decoration: line-through; color: #9aa1ad; }
.dev .d { font-size: 12px; color: #6b7280; margin-top: 2px; }
.dev .del { margin-left: auto; color: #ef4444; background: none; border: 0; font-size: 19px; padding: 4px; }
