:root {
  --bg: #262626;
  --surface: #1d1d1c;
  --ink: #e8e6e1;
  --ink-soft: #8a8a84;
  --line: #3a3a38;
  --accent: #ff6b9d;
  --accent-deep: #e8467a;
  --maternelle: #ffb5c5;
  --primaire: #74c0fc;
  --college: #b197fc;
  --good: #06d6a0;
  --bad: #ffa94d;
  --shadow: 0 1px 2px rgba(0,0,0,.15), 0 8px 24px rgba(0,0,0,.2);
  --shadow-lift: 0 4px 8px rgba(0,0,0,.2), 0 20px 40px rgba(0,0,0,.3);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.breadcrumb {
  font-size: 14px;
  color: var(--ink-soft);
  display: flex;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: #555; }

/* ---------- Main ---------- */
main {
  padding: 40px 40px 80px;
}

h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.hero-sub {
  color: var(--ink-soft);
  font-size: 18px;
  margin: 0 0 48px;
}

/* ---------- Sections ---------- */
.section { margin-bottom: 40px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot, var(--accent));
}
.section.maternelle { --dot: var(--maternelle); }
.section.primaire { --dot: var(--primaire); }
.section.college { --dot: var(--college); }

/* ---------- Class grid ---------- */
.grid {
  display: grid;
  gap: 18px;
}
.grid-stages     { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.grid-maternelle { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-primaire   { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-college    { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-lycee      { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-universite { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: transparent;
}
.card-scene {
  background: linear-gradient(180deg, #2a2a2a 0%, #232322 70%, #1d1d1c 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}
.card-scene svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 280px;
}
.card-text {
  padding: 16px 18px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
}
.card-tag {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
}
.card-name {
  font-weight: 700;
  font-size: 16px;
  margin: 0;
  line-height: 1.2;
}
.card-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 4px 0 0;
}

/* Ambiance par niveau */
.grid-maternelle .card-scene { background: linear-gradient(180deg, #332a1a 0%, #282418 70%, #1d1d1c 100%); }
.grid-college    .card-scene { background: linear-gradient(180deg, #1e2636 0%, #1e222e 70%, #1d1d1c 100%); }
.grid-lycee      .card-scene { background: linear-gradient(180deg, #1e2430 0%, #1e2128 70%, #1d1d1c 100%); }
.grid-universite .card-scene { background: linear-gradient(180deg, #1e1e28 0%, #1d1d22 70%, #1d1d1c 100%); }

/* Cartes de niveau sur la page d'accueil : un peu plus imposantes */
.card-stage .card-scene { min-height: 200px; }
.card-stage .card-name { font-size: 22px; }
.card-stage .card-meta { font-size: 14px; }
.card-stage.stage-maternelle .card-scene { background: linear-gradient(180deg, #332a1a 0%, #282418 70%, #1d1d1c 100%); }
.card-stage.stage-college    .card-scene { background: linear-gradient(180deg, #1e2636 0%, #1e222e 70%, #1d1d1c 100%); }
.card-stage.stage-lycee      .card-scene { background: linear-gradient(180deg, #1e2430 0%, #1e2128 70%, #1d1d1c 100%); }
.card-stage.stage-universite .card-scene { background: linear-gradient(180deg, #1e1e28 0%, #1d1d22 70%, #1d1d1c 100%); }

/* ---------- En-tête + compteur exercice ---------- */
.exo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.exo-header .exo-q-label {
  margin: 0;
  text-align: left;
}
.exo-chrono {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255,107,157,.1);
  padding: 4px 12px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}
.exo-counter {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.exo-counter-num { color: var(--good); }
.exo-counter-total { color: var(--ink-soft); font-weight: 600; }

.exo-bar {
  width: 100%;
  height: 6px;
  background: #333;
  border-radius: 6px;
  overflow: hidden;
  margin: 0 0 22px;
}
.exo-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--good) 0%, #04b88a 100%);
  border-radius: 6px;
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}

.exo-qbox {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn-exit {
  display: none;
  margin: 18px auto 0;
  background: var(--surface);
  border: 2px solid var(--good);
  color: var(--good);
  border-radius: 12px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-exit:hover {
  background: var(--good);
  color: #1d1d1c;
}

.sidebar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-section-count {
  font-weight: 600;
  color: var(--good);
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}

/* Sidebar toggle (Terminés header) */
.sidebar-section-toggle {
  cursor: pointer;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.sidebar-section-toggle:hover { color: var(--ink); }

/* Sidebar subject grouping */
.sidebar-subject {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 4px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.sidebar-subject:first-of-type { margin-top: 4px; }
.sidebar-subject-dot {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--ink);
  flex-shrink: 0;
}

/* ---------- Drawing pad (zone de dessin) ---------- */
.exo-split {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .exo-split { grid-template-columns: 1fr; }
  .exo-split .drawpad { order: 2; }
}
.drawpad {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 88px;
}
.drawpad-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.drawpad-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.drawpad-color:hover { transform: scale(1.1); }
.drawpad-color.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.drawpad-tool {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}
.drawpad-tool:hover { border-color: var(--ink); }
.drawpad-tool.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.drawpad-tool.drawpad-clear { color: var(--bad); border-color: var(--bad); }
.drawpad-tool.drawpad-clear:hover { background: var(--bad); color: #1d1d1c; }
.drawpad-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.drawpad-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #2a2a28;
  border: 1px solid var(--line);
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- Espace Parents ---------- */
.parents-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 0 0 32px;
}
.parents-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.parents-stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--good);
  line-height: 1;
}
.parents-stat-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 8px;
}
.parents-stat-hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.parents-block { margin-bottom: 32px; }
.parents-block h2 {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.parents-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.parents-row {
  display: grid;
  grid-template-columns: 44px 1fr 160px 50px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.parents-row:hover { background: #2a2a28; }
.parents-row-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: white;
}
.parents-row-name { font-weight: 600; font-size: 15px; }
.parents-row-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.parents-bar {
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
}
.parents-bar-fill {
  height: 100%;
  background: var(--good);
  border-radius: 4px;
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
.parents-row-pct {
  font-weight: 700; font-size: 14px;
  color: var(--ink-soft); text-align: right;
}
.parents-empty {
  padding: 16px; color: var(--ink-soft);
  font-size: 14px; margin: 0; text-align: center;
}
.parents-activity {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.parents-activity-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.parents-activity-item:last-child { border-bottom: none; }
.parents-activity-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--good); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.parents-activity-title { font-weight: 600; font-size: 14px; }
.parents-activity-when { font-size: 12px; color: var(--ink-soft); }

/* Bouton Espace Parents dans la sidebar */
.sidebar-parents {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 16px;
  transition: border-color .15s ease;
}
.sidebar-parents:hover { border-color: var(--ink); }
.sidebar-parents.is-current {
  border-color: var(--accent);
  background: #2a1a22;
}
.sidebar-parents-icon {
  width: 28px; height: 28px;
  background: #333;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

/* ---------- Confetti ---------- */
.confetti-layer {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 9999;
}
.confetti-piece {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 2px;
  animation: confetti-burst 1.2s cubic-bezier(.18,.7,.3,1) forwards;
  will-change: transform, opacity;
}
@keyframes confetti-burst {
  0% {
    transform: translate(0, 0) rotate(0);
    opacity: 1;
  }
  70% { opacity: 1; }
  100% {
    transform: translate(var(--tx), calc(var(--ty) + 360px)) rotate(var(--rot));
    opacity: 0;
  }
}

/* ---------- Dashboard : matières ---------- */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.subject-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.subject-card.is-inactive { opacity: 0.55; filter: grayscale(0.6); }
.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  opacity: 1;
  filter: none;
}
.subject-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: white;
  flex: 0 0 auto;
}
.subject-icon.big {
  width: 72px; height: 72px;
  border-radius: 18px; font-size: 28px;
}
.subject-card.is-inactive .subject-icon { background: #444; color: #888; }
.subject-text { min-width: 0; }
.subject-name { font-weight: 700; font-size: 17px; line-height: 1.2; }
.subject-meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Vue matière ---------- */
.subject-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 32px;
}
.subject-hero h1 { margin: 0; }
.subject-hero-meta { color: var(--ink-soft); margin: 4px 0 0; font-size: 14px; }

/* --- Categorie accordeon dans la vue matiere --- */
.subject-category { margin-bottom: 12px; }
.subject-cat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  user-select: none;
}
.subject-cat-header:hover {
  background: #2a2a28;
  border-color: #4a4a48;
  box-shadow: var(--shadow);
}
.subject-cat-header:hover .subject-cat-title { color: #fff; }
.subject-cat-header.is-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-color: var(--cat-color, var(--accent));
  border-bottom-color: var(--line);
}
.subject-cat-arrow {
  font-size: 12px;
  color: var(--ink-soft);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.subject-cat-title {
  font-weight: 700;
  font-size: 1.08rem;
}
.subject-cat-badge {
  font-size: 12px;
  font-weight: 600;
  background: var(--good);
  color: white;
  padding: 2px 10px;
  border-radius: 99px;
}
.subject-cat-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 3px 12px;
  border-radius: 99px;
  font-weight: 500;
}
.subject-cat-content {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-top: none;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  padding: 10px 14px 14px;
}

.subj-exo-list { display: flex; flex-direction: column; gap: 4px; }
.subj-exo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.subj-exo-row:hover { background: #2a2a28; }
.subj-exo-row.is-on { background: #1e2a1e; }
.subj-exo-row input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--good);
  cursor: pointer;
}
.subj-exo-tag {
  flex: 0 0 auto;
  width: 38px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}
.subj-exo-text { min-width: 0; line-height: 1.25; }
.subj-exo-title { font-weight: 600; font-size: 15px; }
.subj-exo-class { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.subj-exo-row.is-done { opacity: .55; }
.subj-exo-row.is-started { background: #2a2820; }
.subj-exo-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.subj-exo-status.done { color: var(--good); }
.subj-exo-q { font-size: 13px; color: var(--ink-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Liste exos sur page classe ---------- */
.exo-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.exo-item-row:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(99,102,241,.10);
}
.exo-item-row.is-done { opacity: .7; }
.exo-item-tag {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  flex: 0 0 auto;
}
.exo-item-text {
  flex: 1 1 auto;
  min-width: 0;
}
.exo-item-text .exo-num { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.exo-item-text .exo-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.exo-item-status {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.exo-item-status.done { color: var(--good); }

/* ---------- Sidebar : programme de l'enfant ---------- */
.with-sidebar {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.sidebar-dashboard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ink);
  color: white;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 16px;
  transition: background .15s ease;
}
.sidebar-dashboard:hover { background: #fff; color: #1d1d1c; }
.sidebar-dashboard.is-current { background: var(--accent); }
.sidebar-dashboard-icon {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-section {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0 8px;
  margin: 0 0 10px;
}
.sidebar-empty {
  padding: 8px 8px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.sidebar-tag {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink);
}
.sidebar-head-text { line-height: 1.2; }
.sidebar-name {
  font-weight: 700;
  font-size: 15px;
}
.sidebar-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
.sidebar-item:hover { background: #2e2e2c; }
.sidebar-item.is-current { background: #2e2e2c; }
.sidebar-item.is-current .sidebar-item-title { color: var(--accent-deep); }
.sidebar-dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, border-color .2s ease;
}
.sidebar-dot.done {
  background: var(--good);
  border-color: var(--good);
}
.sidebar-text { min-width: 0; line-height: 1.25; }
.sidebar-item-num {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sidebar-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-item.is-done .sidebar-item-title { color: var(--ink-soft); }

.class-cta {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0 0 18px;
}
.btn.big {
  display: inline-block;
  font-size: 17px;
  padding: 14px 26px;
  text-decoration: none;
}

/* Layout responsive : la sidebar passe au-dessus en mobile */
@media (max-width: 760px) {
  .with-sidebar {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
}

/* ---------- Class detail ---------- */
.class-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}
.class-hero .card-badge {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  font-size: 24px;
}
.class-hero h1 { margin: 0; font-size: 32px; }
.class-hero p { margin: 4px 0 0; color: var(--ink-soft); }

.exo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.exo-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.exo-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: transparent;
}
.exo-num {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.exo-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}

/* ---------- Exercise view ---------- */
.exo-wrap {
  max-width: 640px;
  margin: 0 auto;
}
.exo-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.exo-q-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.pts-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe88a, #ffd93d 40%, #e6a800 100%);
  box-shadow: 0 0 0 3px #c8940080, inset 0 2px 4px rgba(255,255,255,.5), 0 4px 12px rgba(0,0,0,.3);
  color: #7a5200;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}
.exo-q-text {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
}
.q-calc {
  display: block;
  font-size: 1.3em;
  font-weight: 900;
  margin-top: 8px;
  letter-spacing: 0.04em;
}
.exo-illustration {
  margin: 0 0 32px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.choices {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.choices .choice {
  flex: none;
  width: 100%;
}
.choice-hand {
  padding: 6px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: #2a2a28 !important;
  overflow: hidden;
}
.choice-hand .hand-photo {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  pointer-events: none;
}
.choice-hand.good .hand-photo,
.choice-hand.bad  .hand-photo { filter: brightness(0.92); }
/* .row : ancien alias, conservé pour compat (même comportement) */
.choices.row { /* identique à .choices */ }

.choice {
  background: #2a2a28;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.choice:not(.choice-hand)::before {
  content: attr(data-num);
  flex: 0 0 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,.08);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}
.choice.good::before { background: var(--good); color: #1d1d1c; }
.choice.bad::before { background: var(--bad); color: #1d1d1c; }
.choice:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.choice.good {
  background: var(--good);
  color: #1d1d1c;
  border-color: var(--good);
  animation: pop .3s ease;
}
.choice.bad {
  background: var(--bad);
  color: #1d1d1c;
  border-color: var(--bad);
  animation: shake .35s ease;
}
.choice:disabled { cursor: default; }

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback {
  margin-top: 24px;
  font-size: 18px;
  font-weight: 600;
  min-height: 28px;
}
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.exo-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--ink); }
.btn.primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn.primary:hover { background: #fff; }

/* ---------- Illustrations (visual content for kids) ---------- */
.illu-emoji-row { font-size: 64px; line-height: 1; }
.illu-shape {
  width: 80px; height: 80px;
  display: inline-block;
}
.illu-letter-box {
  width: 70px; height: 70px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 36px;
  color: white;
  background: var(--accent);
}

.dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- Topbar coins ---------- */
/* Topbar right group */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
}
.topbar-stat-icon { font-size: 14px; }
.topbar-stat-val { font-weight: 800; color: var(--ink); }
.topbar-coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  background: linear-gradient(135deg, #ffd93d 0%, #f0c020 100%);
  padding: 5px 14px;
  border-radius: 99px;
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(255, 217, 61, .2);
}
.coin-icon { font-size: 15px; line-height: 1; display: flex; align-items: center; }

/* Pièce 3D réaliste */
.coin-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe066 0%, #ffd93d 30%, #e6b800 70%, #c89e00 100%);
  box-shadow:
    0 1px 0 #b8860b,
    0 2px 0 #a07000,
    0 3px 6px rgba(0,0,0,.35),
    inset 0 1px 2px rgba(255,255,255,.5),
    inset 0 -1px 2px rgba(0,0,0,.2);
  font-size: 11px;
  font-weight: 900;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
  font-family: serif;
  position: relative;
  flex-shrink: 0;
}
.coin-3d::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  border-radius: 50%;
  border: 1.5px solid rgba(184,134,11,.5);
}
.coin-3d::after {
  content: '';
  position: absolute;
  top: 3px; left: 5px;
  width: 8px; height: 5px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.45) 0%, transparent 100%);
}

/* Coin float text animation */
.coin-float {
  position: fixed;
  font-size: 16px;
  font-weight: 800;
  color: #ffd93d;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
  pointer-events: none;
  z-index: 9999;
  animation: coin-rise 1s ease-out forwards;
}
@keyframes coin-rise {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}

/* Coin fly animation (pièce 3D qui vole vers le wallet) */
.coin-fly {
  position: fixed;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe066 0%, #ffd93d 30%, #e6b800 70%, #c89e00 100%);
  box-shadow:
    0 2px 0 #b8860b,
    0 3px 0 #a07000,
    0 4px 10px rgba(0,0,0,.4),
    inset 0 2px 3px rgba(255,255,255,.5),
    inset 0 -2px 3px rgba(0,0,0,.2);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  animation: coin-fly-to-wallet .8s cubic-bezier(.2,.6,.3,1) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
  font-family: serif;
}
.coin-fly::before {
  content: 'E';
}
.coin-fly::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 50%;
  border: 2px solid rgba(184,134,11,.4);
}
@keyframes coin-fly-to-wallet {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  25% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.1), calc(var(--ty) * 0.4 - 40px)) scale(1.1);
  }
  100% {
    opacity: 0.7;
    transform: translate(var(--tx), var(--ty)) scale(0.3);
  }
}

/* Wallet pulse quand une pièce arrive */
.topbar-coins.coin-pulse {
  animation: wallet-pulse .3s ease;
}
@keyframes wallet-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); box-shadow: 0 2px 16px rgba(255,217,61,.6); }
  100% { transform: scale(1); }
}

/* Pièce qui part du wallet vers la mauvaise réponse */
.coin-fly-lose {
  position: fixed;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8888 0%, #e63946 30%, #c0392b 70%, #922b21 100%);
  box-shadow:
    0 2px 0 #7b241c,
    0 3px 0 #641e16,
    0 4px 10px rgba(0,0,0,.4),
    inset 0 2px 3px rgba(255,255,255,.3),
    inset 0 -2px 3px rgba(0,0,0,.2);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  animation: coin-fly-from-wallet .7s cubic-bezier(.3,.1,.7,1) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  font-family: serif;
}
.coin-fly-lose::before {
  content: '−';
}
@keyframes coin-fly-from-wallet {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.3);
  }
  30% {
    opacity: 1;
    transform: translate(calc(var(--tx) * 0.3), calc(var(--ty) * 0.5 + 20px)) scale(0.8);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(1);
  }
}

/* Wallet pulse rouge quand on perd une pièce */
.topbar-coins.coin-pulse-lose {
  animation: wallet-pulse-lose .4s ease;
}
@keyframes wallet-pulse-lose {
  0% { transform: scale(1); }
  30% { transform: scale(0.85); box-shadow: 0 2px 16px rgba(230,57,70,.6); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Texte flottant perte */
.coin-float-lose {
  color: #e63946 !important;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--ink-soft);
}
.footer-powered {
  margin-top: 6px;
  font-size: 12px;
  opacity: .7;
}
.footer-powered a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- OneNote-style Dashboard ---------- */
.nb-page { margin: 0; }
body.has-rates-panel main { margin-right: 280px; }
body.has-rates-panel .footer { margin-right: 280px; }

/* --- Stats cards row --- */
.nb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.nb-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.nb-stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex: 0 0 auto;
}
.nb-stat-body { flex: 1 1 auto; }
.nb-stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.nb-stat-label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

/* --- Section headers --- */
.nb-section { margin-bottom: 32px; }
.nb-section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--ink);
}
.nb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.nb-section-header .nb-section-title { margin: 0; }

/* --- Rates panel: fixed right edge of screen --- */
.nb-rates-panel {
  position: fixed;
  top: 70px;
  right: 0;
  bottom: 0;
  width: 280px;
  background: #1a1a19;
  border-left: 1px solid var(--line);
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 5;
}
.nb-rates-panel .nb-section-title {
  font-size: 15px;
  margin-bottom: 14px;
}
.nb-rates-panel .nb-rate-card {
  border: none;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.nb-rates-panel .nb-rate-card:last-child { border-bottom: none; }

/* Sub-groups inside stage accordion */
.nb-sub-group { margin: 4px 0 8px; }
.nb-sub-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #2a2a28;
  border-radius: 8px;
  margin-bottom: 4px;
}
.nb-sub-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.nb-sub-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}
.nb-sub-list {
  padding-left: 12px;
  border-left: 2px solid #3a3a38;
  margin-left: 10px;
}
.nb-exo-row.nb-sub-row { padding: 8px 10px; }
.nb-exo-tag.small {
  width: 30px; height: 30px;
  border-radius: 7px;
  font-size: 10px;
}
.nb-rate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.nb-rate-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.nb-rate-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}
.nb-rate-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.nb-rate-pct {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.nb-rate-bar {
  height: 6px;
  background: #333;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.nb-rate-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width .4s ease;
}
.nb-rate-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

/* --- OneNote Notebook tabs --- */
/* --- Fixed left sidebar: subject tabs --- */
.nb-tabs {
  position: fixed;
  left: 0;
  top: 70px;
  bottom: 0;
  width: 200px;
  display: flex;
  flex-direction: column;
  background: #1a1a19;
  border-right: 1px solid var(--line);
  padding: 8px 0;
  overflow-y: auto;
  z-index: 5;
}
body.has-tabs-panel main { margin-left: 200px; }
body.has-tabs-panel .footer { margin-left: 200px; }
body.has-tabs-panel .nb-page { max-width: none; }

/* --- Center content area --- */
.nb-center {
  min-height: calc(100vh - 200px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
}
.nb-center-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.nb-center-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}
.nb-center-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}

/* --- Inline exercise (plein centre, épuré) --- */
.nb-inline-wrap {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  padding: 0;
}
/* Ligne du haut : Retour + barre progression */
.nb-inline-toprow {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 8px;
}
.nb-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color .15s;
}
.nb-back-btn:hover { color: var(--ink); }

.nb-inline-exo {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 24px 20px;
  box-shadow: none;
  text-align: center;
}
.nb-inline-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 24px;
}
.nb-inline-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}
.nb-inline-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}
.nb-inline-counter {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  min-width: 56px;
}
.nb-inline-bar {
  flex: 1;
  height: 5px;
  background: #333;
  border-radius: 6px;
  overflow: hidden;
}
.nb-inline-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--good) 0%, #04b88a 100%);
  border-radius: 6px;
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
.nb-inline-exo .exo-q-text {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 48px;
  color: var(--ink);
}
.nb-inline-exo .exo-illustration {
  margin: 0 0 40px;
}
.nb-inline-exo .choices {
  max-width: 600px;
  width: 100%;
  gap: 16px;
}
.nb-inline-exo .choice {
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 220px;
  padding: 22px 24px;
  font-size: 22px;
  border-radius: 16px;
}
.nb-inline-exo .feedback {
  margin-top: 32px;
  font-size: 20px;
}
.nb-inline-exo .btn-exit {
  margin-top: 24px;
  padding: 12px 28px;
  font-size: 15px;
}

/* --- Calcul posé (opération en colonnes) --- */
.calc-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
}
.calc-layout > .exo-q-text {
}
.calc-layout > .calc-pose {
  align-self: center;
}
.calc-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}
.calc-pose {
  flex: 0 0 auto;
  background: #2a2a28;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: 'Courier New', monospace;
  font-size: 32px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.6;
  min-width: 140px;
}
.calc-pose-line {
  display: flex;
  align-items: center;
}
.calc-pose-digit {
  width: 32px;
  text-align: center;
}
.calc-pose-op {
  width: 32px;
  text-align: center;
  color: var(--accent);
  font-weight: 800;
}
.calc-pose-bar {
  width: 100%;
  height: 3px;
  background: var(--ink);
  border-radius: 2px;
  margin: 4px 0;
}
/* Ligne retenues (petits chiffres au-dessus) */
.calc-pose-retenue {
  height: 24px;
  margin-bottom: 2px;
}
.calc-pose-ret-input {
  width: 32px;
  height: 22px;
  border: none;
  border-bottom: 1.5px dashed #555;
  background: transparent;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  outline: none;
  padding: 0;
  caret-color: var(--accent);
}
.calc-pose-ret-input:focus {
  border-bottom-color: var(--accent);
  background: rgba(255,107,157,.08);
  border-radius: 4px 4px 0 0;
}
.calc-pose-op-space {
  visibility: hidden;
}

/* Ligne résultat : inputs éditables */
.calc-pose-input {
  width: 32px;
  height: 40px;
  border: 1.5px dashed #555;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-family: 'Courier New', monospace;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  outline: none;
  padding: 0;
  margin: 0;
  caret-color: var(--good);
  transition: border-color .15s, background .15s;
  box-sizing: content-box;
}
.calc-pose-input::placeholder {
  color: #555;
  font-size: 22px;
}
.calc-pose-input:focus {
  border-color: var(--good);
  background: rgba(6,214,160,.1);
}
.calc-pose-input:not(:placeholder-shown) {
  border-style: solid;
  border-color: var(--good);
}
.calc-pose-input.pose-correct {
  border-style: solid;
  border-color: #06d6a0;
  background: rgba(6, 214, 160, .2);
  color: #06d6a0;
  animation: pose-flash-good .4s ease;
}
.calc-pose-input.pose-wrong {
  border-style: solid;
  border-color: #e63946;
  background: rgba(230, 57, 70, .2);
  color: #e63946;
  animation: pose-flash-bad .5s ease;
}
@keyframes pose-flash-good {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes pose-flash-bad {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.calc-pose-result {
  margin-top: 4px;
  gap: 0;
}

@media (max-width: 600px) {
  .calc-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
  }
  .calc-pose {
    font-size: 24px;
    padding: 16px 20px;
  }
  .calc-pose-digit, .calc-pose-op {
    width: 24px;
  }
  .calc-pose-input {
    width: 24px;
    height: 32px;
    font-size: 20px;
  }
  .calc-pose-ret-input {
    width: 24px;
    height: 20px;
    font-size: 14px;
  }
}

/* --- Legacy notebook grid (for other views) --- */
.nb-notebook {
  display: grid;
  grid-template-columns: 200px 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
  overflow: hidden;
  min-height: 320px;
}
.nb-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, background .15s;
  position: relative;
  border: none;
}
.nb-tab::before {
  content: '';
  position: absolute;
  top: 4px; bottom: 4px; left: 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--tab-color);
  opacity: 0;
  transition: opacity .15s;
}
.nb-tab:hover {
  color: var(--ink);
  background: rgba(255,255,255,.06);
}
.nb-tab.is-active {
  color: var(--ink);
  background: var(--surface);
}
.nb-tab.is-active::before { opacity: 1; }
.nb-tab-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--tab-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}
.nb-tab-label { font-size: 13px; }

.nb-tab-content {
  padding: 20px 24px;
  min-height: 200px;
  overflow-y: auto;
}

/* --- Exercise groups inside tab --- */
.nb-exo-group { margin-bottom: 6px; }
.nb-exo-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
}
.nb-exo-group-header:hover { background: #262626; color: #fff; }
.nb-exo-group-header:hover .nb-group-label { color: #fff; }
.nb-exo-group-header.is-open { background: #2e2e2c; }
.nb-group-arrow {
  font-size: 10px;
  color: #666;
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
}
.nb-exo-group-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.nb-group-label {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.nb-group-count {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  background: #333;
  padding: 2px 8px;
  border-radius: 8px;
}
.nb-group-done {
  font-size: 11px;
  font-weight: 700;
  color: var(--good);
}
.nb-exo-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 22px;
  padding-bottom: 6px;
}
.nb-exo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.nb-exo-row:hover { background: #2e2e2c; }
.nb-exo-row:hover .nb-exo-title { color: #fff; }
.nb-exo-row.is-done { opacity: .65; }
.nb-exo-tag {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  flex: 0 0 auto;
}
.nb-exo-info { flex: 1; min-width: 0; }
.nb-exo-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.nb-exo-cls {
  font-size: 12px;
  color: var(--ink-soft);
}
.nb-exo-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.nb-exo-status.done { color: var(--good); }
.nb-exo-go {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.nb-empty {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 24px 0;
}

/* --- Planning --- */
.nb-btn-add {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.nb-btn-add:hover { background: var(--accent-deep); }

.nb-planning { margin-top: 4px; }
.nb-plan-day { margin-bottom: 16px; }
.nb-plan-date {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.nb-plan-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nb-plan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.nb-plan-item:hover { background: #2e2e2c; }
.nb-plan-item.is-done { opacity: .6; }
.nb-plan-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  flex: 0 0 auto;
}
.nb-plan-dot.done {
  background: var(--good);
  border-color: var(--good);
  color: white;
}
.nb-plan-text {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nb-plan-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: rgba(177,151,252,.2);
  color: #b197fc;
  padding: 2px 7px;
  border-radius: 6px;
}
.nb-plan-del {
  background: none;
  border: none;
  color: #555;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color .12s;
}
.nb-plan-del:hover { color: #e63946; }

/* --- Calendrier Planning --- */
.nb-calendar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.nb-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.nb-cal-month {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.nb-cal-nav {
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}
.nb-cal-nav:hover {
  background: #2a2a28;
  border-color: var(--ink-soft);
  color: var(--ink);
}
.nb-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.nb-cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px 0 6px;
}
.nb-cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-radius: 10px;
  padding: 6px 2px 4px;
  min-height: 52px;
  position: relative;
  transition: background .12s;
}
.nb-cal-day.nb-cal-empty { min-height: 0; }
.nb-cal-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.nb-cal-day.is-today .nb-cal-num {
  background: var(--accent);
  color: white;
  font-weight: 800;
}
.nb-cal-day.has-activity {
  cursor: pointer;
  background: #2a2a28;
}
.nb-cal-day.has-activity:hover {
  background: #333;
}
.nb-cal-day.is-selected {
  background: #333;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.nb-cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.nb-cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* Légende matières sous le calendrier */
.nb-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0 0;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.nb-cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}
.nb-cal-legend-item .nb-cal-dot {
  width: 8px;
  height: 8px;
}

/* Détail du jour sélectionné */
.nb-cal-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1.5px solid var(--line);
  animation: cal-slide-in .25s ease;
}
@keyframes cal-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nb-cal-detail-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  text-transform: capitalize;
}
.nb-cal-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background .12s;
}
.nb-cal-entry:hover { background: #2e2e2c; }
.nb-cal-entry.is-done { opacity: .75; }
.nb-cal-entry-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nb-cal-entry-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}
.nb-cal-entry-info { flex: 1; min-width: 0; }
.nb-cal-entry-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.nb-cal-entry-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.nb-cal-entry-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.nb-cal-entry-badge.done {
  background: rgba(6,214,160,.15);
  color: var(--good);
}
.nb-cal-entry-badge.pending {
  background: rgba(255,169,77,.15);
  color: var(--bad);
}

/* --- Modal pour ajouter exercice au planning --- */
.nb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.nb-modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.nb-modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}
.nb-modal-search {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .15s;
}
.nb-modal-search:focus { border-color: var(--accent); }
.nb-modal-list {
  flex: 1;
  overflow-y: auto;
  max-height: 340px;
}
.nb-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background .12s;
}
.nb-modal-item:hover { background: #333; }
.nb-modal-item-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: white;
  flex: 0 0 auto;
}
.nb-modal-close {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: #333;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s;
}
.nb-modal-close:hover { background: #444; }

/* ---------- Themed exercise backgrounds (désactivés en dark mode) ---------- */
.exo-theme-maternelle,
.exo-theme-primaire,
.exo-theme-college,
.exo-theme-lycee,
.exo-theme-universite {
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.exo-theme-maternelle::before,
.exo-theme-universite::before { display: none; }
.exo-theme-maternelle .exo-q,
.exo-theme-primaire .exo-q,
.exo-theme-college .exo-q,
.exo-theme-lycee .exo-q,
.exo-theme-universite .exo-q {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .nb-stats { grid-template-columns: repeat(2, 1fr); }
  .nb-rates-panel { display: none; }
  body.has-rates-panel main { margin-right: 0; }
  body.has-rates-panel .footer { margin-right: 0; }

  /* Mobile : tabs become a full vertical tile list */
  .nb-tabs {
    position: static;
    width: auto;
    flex-direction: column;
    overflow-x: visible;
    border-right: none;
    border-bottom: none;
    border-radius: 12px;
    padding: 6px;
    box-shadow: none;
    gap: 2px;
  }
  body.has-tabs-panel main { margin-left: 0; }
  body.has-tabs-panel .footer { margin-left: 0; }
  .nb-tab {
    padding: 14px 16px;
    gap: 12px;
    border-radius: 10px;
    font-size: 15px;
  }
  .nb-tab-icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    font-size: 15px;
  }
  .nb-tab-label { display: inline; font-size: 15px; }
  .nb-tab::before {
    top: 4px; bottom: 4px; left: 0;
    width: 4px; height: auto;
    border-radius: 0 4px 4px 0;
  }
  .nb-tabs.has-selection .nb-tab:not(.is-active) { display: none; }
  .nb-tabs.has-selection { border-radius: 12px 12px 0 0; padding-bottom: 0; }
  .nb-center {
    border-radius: 0 0 12px 12px;
    border-top: none;
  }

  .nb-notebook { grid-template-columns: 1fr; }
  .nb-tab-content { padding: 16px; }

  .topbar-stat { display: none; }
  .topbar-coins { padding: 4px 10px; font-size: 13px; }
  .topbar { gap: 12px; padding: 14px 16px; }
  .breadcrumb { font-size: 12px; }
  .brand { font-size: 17px; gap: 7px; }

  .subject-cat-header { padding: 12px 14px; gap: 8px; }
  .subject-cat-title { font-size: 1rem; }
  .subject-cat-count { font-size: 12px; padding: 2px 8px; }

  .parents-stats { grid-template-columns: 1fr; }
  .parents-row { flex-wrap: wrap; }

  .drawpad-canvas { width: 100% !important; height: auto !important; }
}

@media (max-width: 600px) {
  main { padding: 24px 14px 60px; }
  h1 { font-size: 26px; }

  .exo-q { padding: 24px 16px; border-radius: 14px; }
  .exo-q-text { font-size: 20px; }
  .choice { font-size: 16px; padding: 12px 14px; gap: 12px; }
  .choice:not(.choice-hand)::before { flex: 0 0 30px; height: 30px; font-size: 14px; border-radius: 8px; }
  .choice-hand { padding: 6px; }
  .hand-photo { max-width: 80px; }

  .exo-header { flex-wrap: wrap; gap: 8px; }
  .exo-counter { font-size: 14px; }
  .exo-nav { flex-direction: column; }

  .nb-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .nb-stat-card { padding: 14px; }
  .nb-stat-value { font-size: 20px; }

  .sidebar-item-num { font-size: 13px; }
  .sidebar-item-title { font-size: 12px; }
}

@media (max-width: 400px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 15px; }
  .breadcrumb { display: none; }
  .nb-stat-icon { width: 36px; height: 36px; font-size: 18px; }
  h1 { font-size: 22px; }
}

/* ---------- Auth area ---------- */
#auth-area { flex: 0 0 auto; }
.auth-login-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.auth-login-btn:hover { background: var(--accent-deep); }
.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 10px 4px 4px;
}
.auth-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}
.auth-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-logout {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color .15s;
}
.auth-logout:hover { color: #e63946; }

/* Auth Modal */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.auth-modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-modal h3 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 20px;
  text-align: center;
}
.auth-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.auth-input:focus { border-color: var(--accent); }
.auth-error {
  font-size: 13px;
  color: #e63946;
  min-height: 18px;
  margin: 0 0 12px;
  text-align: center;
}
.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  font-family: inherit;
}
.auth-google:hover { background: #f7f7f7; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--ink-soft);
  font-size: 13px;
}
.auth-separator::before, .auth-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ink-soft);
  opacity: .3;
}
.auth-submit {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.auth-submit:hover { background: var(--accent-deep); }
.auth-switch {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin: 14px 0 0;
}
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }
.auth-close {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #333;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s;
  font-family: inherit;
}
.auth-close:hover { background: #444; color: var(--ink); }

@media (max-width: 600px) {
  .auth-name { display: none; }
  .auth-modal { padding: 24px 20px; }
}
