/* ============================================================
   TRAKmy Academy — charte stricte
   teal #176e84 · teal foncé #0b5a6e · bleu clair #76b5c3
   orange CTA #ec733f · beige #d6cbc8 · gris #8a8988
   ============================================================ */
:root {
  --teal: #176e84;
  --teal-dark: #0b5a6e;
  --blue-light: #76b5c3;
  --orange: #ec733f;
  --orange-dark: #d65f2e;
  --beige: #d6cbc8;
  --grey: #8a8988;
  --ink: #1b3a44;
  --bg: #f4f7f8;
  --card: #ffffff;
  --line: #e2eaec;
  --ok: #2e9e5b;
  --ko: #cc4433;
  --amber: #d9a114;
  --r: 14px;
  --shadow: 0 2px 10px rgba(11, 90, 110, .08), 0 1px 3px rgba(11, 90, 110, .06);
  --shadow-lift: 0 8px 28px rgba(11, 90, 110, .16);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55; min-height: 100vh;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { letter-spacing: -.01em; }

/* ---------- Boutons ---------- */
.btn { border: none; border-radius: 10px; padding: 13px 22px; font-weight: 700; font-size: 1rem; transition: transform .12s, box-shadow .12s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-cta { background: var(--orange); color: #fff; box-shadow: 0 3px 10px rgba(236, 115, 63, .35); }
.btn-cta:hover { background: var(--orange-dark); box-shadow: 0 5px 16px rgba(236, 115, 63, .45); }
.btn-cta:disabled { background: #f0b394; box-shadow: none; cursor: default; }
.btn-soft { background: #fff; color: var(--teal-dark); border: 1.5px solid var(--blue-light); }
.btn-soft:hover { background: #eef6f8; }
.btn-block { width: 100%; }

/* ---------- Login ---------- */
.view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px;
  background: linear-gradient(150deg, var(--teal-dark) 0%, var(--teal) 52%, var(--blue-light) 130%);
}
.login-card {
  background: var(--card); border-radius: 20px; box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
  padding: 40px 32px 34px; width: 100%; max-width: 410px; text-align: center;
  animation: rise .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.login-logo { width: 210px; max-width: 70%; margin-bottom: 10px; }
.login-card h1 { color: var(--teal-dark); font-size: 1.5rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.login-sub { color: var(--grey); font-size: .88rem; margin: 4px 0 24px; }
#login-form { text-align: left; }
#login-form label { display: block; font-size: .8rem; font-weight: 700; color: var(--teal-dark); margin: 14px 0 5px; text-transform: uppercase; letter-spacing: .05em; }
#login-form input {
  width: 100%; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 1rem; background: #fafcfd; transition: border-color .15s, box-shadow .15s;
}
#login-form input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23, 110, 132, .12); }
#login-form .btn { margin-top: 24px; }
.login-error { color: var(--ko); font-size: .86rem; margin-top: 12px; text-align: center; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal));
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; padding-top: calc(9px + env(safe-area-inset-top));
  box-shadow: 0 2px 12px rgba(11, 90, 110, .25);
}
.topbar-logo { background: none; border: none; padding: 0; display: flex; align-items: center; }
.topbar-logo img { height: 30px; display: block; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.chip-streak { color: #fff; font-size: .85rem; font-weight: 700; background: rgba(255, 255, 255, .16); border-radius: 20px; padding: 4px 12px; }
.hdr-user { color: #d9edf2; font-size: .85rem; }
.btn-logout { background: rgba(255, 255, 255, .14); color: #fff; border: none; border-radius: 8px; width: 32px; height: 32px; font-size: 1rem; }
.btn-logout:hover { background: rgba(255, 255, 255, .28); }

main { max-width: 880px; margin: 0 auto; padding: 18px 14px 96px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -3px 14px rgba(11, 90, 110, .09);
}
.nb {
  flex: 1; background: none; border: none; padding: 8px 2px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: .64rem; font-weight: 700; color: var(--grey); transition: color .15s;
}
.nb-ico { font-size: 1.3rem; transition: transform .15s; }
.nb.active { color: var(--orange); }
.nb.active .nb-ico { transform: translateY(-2px) scale(1.08); }

/* ---------- Cartes ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px; }
.page-title { color: var(--teal-dark); font-size: 1.35rem; margin: 2px 0 4px; font-weight: 800; }
.page-sub { color: var(--grey); font-size: .88rem; margin-bottom: 16px; }
.pill { display: inline-block; font-size: .7rem; font-weight: 800; border-radius: 20px; padding: 3px 11px; background: #e6f0f3; color: var(--teal-dark); margin-right: 6px; letter-spacing: .03em; text-transform: uppercase; }
.pill.orange { background: #fdeade; color: var(--orange-dark); }
.pill.beige { background: var(--beige); color: #6a5a54; }
.pill.ok { background: #e2f3e9; color: var(--ok); }
.pill.ko { background: #f9e5e1; color: var(--ko); }

/* ---------- Accueil ---------- */
.hero {
  border-radius: 18px; padding: 24px 22px; margin-bottom: 16px; color: #fff;
  background:
    radial-gradient(120% 160% at 100% 0%, rgba(118, 181, 195, .35) 0%, transparent 45%),
    linear-gradient(140deg, var(--teal-dark), var(--teal));
  box-shadow: var(--shadow-lift);
}
.hero h2 { font-size: 1.35rem; margin-bottom: 2px; }
.hero .sub { font-size: .9rem; opacity: .9; }
.hero-day { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.day-badge {
  background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 14px; padding: 10px 18px; text-align: center; min-width: 90px;
}
.day-badge .n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.day-badge .l { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.hero-day .btn-cta { padding: 14px 26px; font-size: 1.02rem; }
.hero-done { font-size: .95rem; background: rgba(255,255,255,.13); border-radius: 12px; padding: 12px 16px; }
.progress-track { height: 9px; background: #e6eef1; border-radius: 6px; overflow: hidden; }
.progress-track.on-dark { background: rgba(255, 255, 255, .22); }
.progress-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue-light), var(--orange)); transition: width .5s cubic-bezier(.2, .8, .3, 1); }
.prog-note { display: flex; justify-content: space-between; font-size: .76rem; color: var(--grey); margin-top: 5px; }
.hero .prog-note { color: #d9edf2; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 12px; text-align: center; }
.stat-tile .v { font-size: 1.45rem; font-weight: 800; color: var(--teal-dark); }
.stat-tile .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); font-weight: 700; }

/* ---------- Session player ---------- */
.player-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.player-quit { background: none; border: none; color: var(--grey); font-size: .82rem; font-weight: 700; }
.player-prog { flex: 1; }
.global-timer { font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 700; color: var(--teal-dark); background: #e6f0f3; padding: 4px 12px; border-radius: 20px; }
.global-timer.over { color: var(--ko); background: #f9e5e1; }

.timer-wrap { display: flex; justify-content: center; margin: 2px 0 10px; }
.ring { width: 74px; height: 74px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: #e6eef1; }
.ring .arc { stroke: var(--teal); stroke-linecap: round; transition: stroke-dashoffset .95s linear, stroke .3s; }
.ring.warn .arc { stroke: var(--amber); }
.ring.danger .arc { stroke: var(--ko); }
.ring .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.ring.danger .t { color: var(--ko); animation: pulse .8s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

.q-card { animation: rise .3s ease; }
.q-text { font-size: 1.06rem; font-weight: 650; margin: 10px 0 14px; }
.q-context { font-size: .92rem; color: #5d7078; font-style: italic; margin-bottom: 8px; }
.cas-box { background: #f6f9fa; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin: 10px 0; font-size: .88rem; }
.cas-box h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-dark); margin-bottom: 6px; }
.cas-box ol { margin-left: 18px; }
.cas-fold { max-height: 74px; overflow: hidden; position: relative; cursor: pointer; }
.cas-fold::after { content: "▾ tout afficher"; position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: .74rem; font-weight: 700; color: var(--teal); background: linear-gradient(transparent, #f6f9fa 65%); padding-top: 26px; }
.cas-fold.open { max-height: none; }
.cas-fold.open::after { display: none; }

/* Choix (qcm / vf / meilleure / drill) */
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; background: #fbfdfe; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 15px; font-size: .94rem; transition: border-color .12s, background .12s, transform .12s;
}
.choice:hover:not(:disabled) { border-color: var(--blue-light); background: #f2f8fa; }
.choice:disabled { cursor: default; }
.choice.sel { border-color: var(--teal); background: #eaf4f7; }
.choice.correct { border-color: var(--ok); background: #e9f7ee; font-weight: 600; animation: goodpop .4s; }
.choice.wrong { border-color: var(--ko); background: #fbeae6; animation: shake .35s; }
@keyframes goodpop { 30% { transform: scale(1.015); } }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }

/* Remise en ordre */
.order-list { display: flex; flex-direction: column; gap: 9px; }
.order-item {
  display: flex; align-items: center; gap: 10px; background: #fbfdfe; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 11px 13px; font-size: .92rem; user-select: none;
}
.order-item .grip { color: var(--grey); font-size: 1.05rem; cursor: grab; touch-action: none; padding: 4px 2px; }
.order-item.dragging { opacity: .6; border-style: dashed; }
.order-item .num { background: var(--teal); color: #fff; min-width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; }
.order-item .mv { display: flex; flex-direction: column; gap: 2px; margin-left: auto; }
.order-item .mv button { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 28px; height: 22px; font-size: .7rem; color: var(--teal-dark); }
.order-item.good { border-color: var(--ok); background: #e9f7ee; }
.order-item.bad { border-color: var(--ko); background: #fbeae6; }

/* Repérer la faute */
.segments { display: flex; flex-direction: column; gap: 8px; }
.seg { text-align: left; background: #fbfdfe; border: 1.5px dashed var(--line); border-radius: 12px; padding: 11px 14px; font-size: .93rem; }
.seg:hover:not(:disabled) { border-color: var(--amber); background: #fdf7e8; }
.seg.correct { border: 1.5px solid var(--ok); background: #e9f7ee; }
.seg.wrong { border: 1.5px solid var(--ko); background: #fbeae6; animation: shake .35s; }
.seg-hint { font-size: .8rem; color: var(--grey); margin-bottom: 8px; }

/* Texte à trous */
.trous-text { font-size: .98rem; line-height: 2.1; }
.gap-select {
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--teal-dark);
  border: 1.5px solid var(--blue-light); border-radius: 8px; padding: 4px 8px; background: #f2f8fa; margin: 0 2px;
}
.gap-select.good { border-color: var(--ok); background: #e9f7ee; }
.gap-select.bad { border-color: var(--ko); background: #fbeae6; }

/* Pick N parmi M */
.pick-note { font-size: .82rem; font-weight: 700; color: var(--teal-dark); margin-bottom: 8px; }
.choice.picked { border-color: var(--orange); background: #fdf0e8; }
.choice.missed { border-color: var(--amber); background: #fdf7e8; }

.validate-row { margin-top: 16px; display: flex; justify-content: flex-end; }

/* Feedback */
.feedback { margin-top: 16px; animation: rise .3s ease; }
.verdict { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; margin-bottom: 10px; }
.verdict.ok { color: var(--ok); } .verdict.ko { color: var(--ko); }
.explain { border-left: 4px solid var(--teal); background: #eef6f8; border-radius: 0 12px 12px 0; padding: 13px 15px; font-size: .92rem; margin-bottom: 10px; }
.explain .src { display: block; margin-top: 8px; font-size: .77rem; color: var(--grey); font-style: italic; }
.modele-box { border-left: 4px solid var(--ok); background: #eff8f2; border-radius: 0 12px 12px 0; padding: 13px 15px; font-size: .92rem; margin-bottom: 10px; }
.modele-box h5 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ok); margin-bottom: 5px; }
.next-row { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ---------- Fin de session ---------- */
.finish { text-align: center; padding: 26px 18px; }
.finish .score-big { font-size: 3.4rem; font-weight: 800; color: var(--teal-dark); line-height: 1.1; }
.finish .score-pct { font-size: 1.1rem; color: var(--grey); font-weight: 700; margin-bottom: 8px; }
.finish .compare { font-size: .95rem; margin: 8px 0 4px; }
.finish .compare b.up { color: var(--ok); } .finish .compare b.down { color: var(--orange-dark); }
.finish-chart { max-width: 460px; margin: 14px auto; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ---------- Modules libres ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.mod-card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 17px;
  text-align: left; border: 1.5px solid transparent; transition: border-color .15s, transform .15s, box-shadow .15s; width: 100%;
}
.mod-card:hover { border-color: var(--blue-light); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.mod-card h3 { color: var(--teal-dark); font-size: 1rem; }
.mod-card .d { color: var(--grey); font-size: .8rem; margin: 3px 0 10px; }
.freewarn { background: #fdf7e8; border-left: 4px solid var(--amber); border-radius: 0 12px 12px 0; padding: 11px 14px; font-size: .84rem; margin-bottom: 14px; }

/* ---------- Battle card ---------- */
.bc-theme { margin-bottom: 12px; }
.bc-head {
  width: 100%; text-align: left; background: linear-gradient(90deg, var(--teal), var(--teal-dark)); color: #fff; border: none;
  border-radius: 12px; padding: 14px 17px; font-size: 1rem; font-weight: 800;
  display: flex; justify-content: space-between; align-items: center;
}
.bc-head .chev { transition: transform .2s; }
.bc-theme.open .chev { transform: rotate(90deg); }
.bc-body { display: none; padding-top: 10px; }
.bc-theme.open .bc-body { display: block; }
.bc-line { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 15px 16px; margin-bottom: 10px; }
.bc-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.bc-cell { border-radius: 10px; padding: 11px 13px; font-size: .87rem; }
.bc-cell h5 { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.bc-sens { background: #f1eef7; } .bc-sens h5 { color: #7a5ea8; }
.bc-trak { background: #e8f2f5; } .bc-trak h5 { color: var(--teal-dark); }
.bc-angle { background: #fdf0e8; border-radius: 10px; padding: 11px 13px; font-size: .87rem; margin-bottom: 8px; }
.bc-angle h5 { font-size: .7rem; text-transform: uppercase; color: var(--orange-dark); margin-bottom: 4px; }
.bc-say { background: var(--teal-dark); color: #fff; border-radius: 10px; padding: 12px 14px; font-size: .9rem; font-style: italic; }
.bc-say h5 { font-size: .7rem; text-transform: uppercase; color: var(--blue-light); margin-bottom: 4px; font-style: normal; }
.bc-warn { background: #fdf7e8; border-left: 4px solid var(--amber); border-radius: 0 12px 12px 0; padding: 12px 15px; font-size: .84rem; margin-bottom: 14px; }

/* ---------- Dashboards ---------- */
.chart-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.chart-card h3 { color: var(--teal-dark); font-size: .95rem; margin-bottom: 10px; }
.chart-wrap { position: relative; width: 100%; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th { text-align: left; color: var(--grey); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 8px; border-bottom: 2px solid var(--line); }
.admin-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.trend-up { color: var(--ok); font-weight: 800; }
.trend-down { color: var(--ko); font-weight: 800; }
.fail-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-size: .86rem; background: #fbfdfe; }
.fail-item .meta { color: var(--grey); font-size: .76rem; margin-top: 3px; }
.table-scroll { overflow-x: auto; }

.empty { text-align: center; color: var(--grey); padding: 34px 10px; font-size: .92rem; }

@media (max-width: 560px) {
  .bc-duo { grid-template-columns: 1fr; }
  main { padding: 14px 10px 92px; }
  .card { padding: 16px 14px; }
  .hero { padding: 20px 17px; }
  .hero-day .btn-cta { width: 100%; }
  .topbar-logo img { height: 26px; }
}

/* ---------- V3 ---------- */
.btn-rename { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .75rem; cursor: pointer; vertical-align: 1px; }
.btn-rename:hover { border-color: var(--teal); background: #eef6f8; }

/* ---------- Bugfix feedback trous : la bonne réponse s'affiche À CÔTÉ du choix (jamais à sa place) ---------- */
.gap-correct {
  display: inline-block; margin: 0 4px; padding: 3px 10px; border-radius: 8px;
  background: #e9f7ee; border: 1.5px solid var(--ok); color: var(--ok);
  font-size: .85rem; font-weight: 700; white-space: nowrap;
}
