:root {
  --bg: #0f1626; --panel: #16213a; --panel-2: #1c2a4a; --border: #2a3a5f;
  --text: #e8ecf4; --muted: #93a1bd; --accent: #38bdf8; --green: #34d399;
  --card-bg: #eefaf3; --card-border: #b7e3cd; --card-text: #1f3d2b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
h1 { font-size: 19px; }
.subtitle { font-size: 12px; color: var(--muted); }
nav { display: flex; gap: 8px; }
.nav-btn {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.nav-btn:hover, .nav-btn.active { border-color: var(--accent); color: var(--accent); }

.layout { display: flex; flex: 1; min-height: 0; position: relative; }
#sidebar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: min(360px, 92vw);
  background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 20;
  transition: transform .25s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,.45);
}
#sidebar.hidden { transform: translateX(-106%); box-shadow: none; }
.sidebar-head { padding: 14px 16px 8px; }
.sidebar-head h2 { font-size: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#controls {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.step { display: flex; align-items: center; gap: 10px; }
.step-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #06222f; font-size: 11px; margin-right: 6px;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--accent); color: #06222f; border-color: var(--accent); font-weight: 600; }

#stage { flex: 1; position: relative; overflow-y: auto; padding: 18px 22px; background: #f6f1e7; }

/* ---- Cartes lexique (style sos-cartables) ---- */
#cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  align-items: start;
}
@media (max-width: 900px) { #cards { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--card-bg); border: 2px solid var(--card-border);
  border-radius: 10px; cursor: pointer; overflow: hidden;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,60,40,.15); border-color: var(--green); }
.card.open { border-color: var(--green); box-shadow: 0 6px 20px rgba(20,60,40,.18); }
.card .t {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 10px; font-weight: 700; font-size: 15px; color: var(--card-text);
  text-align: center;
}
.card .t .ic { font-size: 20px; }
.card .d {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
  color: #33523f; font-size: 13.5px; line-height: 1.55; font-style: italic;
}
.card.open .d { max-height: 300px; }
.card .d .inner { padding: 0 14px 14px; text-align: center; }
.card.quiz-target { cursor: pointer; }
.card.good { border-color: var(--green); background: #d9f7e6; }
.card.bad { border-color: #ef4444; background: #fde8e8; }
.card.answer { outline: 3px solid var(--green); outline-offset: 2px; }

#quiz-bar {
  background: var(--card-bg); border: 2px solid var(--card-border);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 14px;
  color: var(--card-text); text-align: center;
}
#quiz-def { font-size: 16px; font-style: italic; line-height: 1.5; }
#quiz-hint { font-size: 12px; color: #5c7a68; margin-top: 6px; font-weight: 600; }
#quiz-score { font-size: 13px; font-weight: 700; color: var(--green); }

/* ---- Cartes d'identité (style SOS Cartables) ---- */
#cards.idcards { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { #cards.idcards { grid-template-columns: 1fr; } }
.idcard {
  border: 3px solid var(--cc); border-radius: 16px; overflow: hidden;
  background: #fff;
}
.id-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-weight: 800; font-size: 17px;
  color: #1b3a6b; background: color-mix(in srgb, var(--cc) 18%, white);
}
.id-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; border-radius: 12px;
  background: var(--cc); color: #fff; font-size: 18px; font-weight: 800;
}
.id-body { padding: 10px 16px 14px; }
.id-top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.id-group {
  flex: 1; font-size: 15px; color: #1b3a6b;
  background: color-mix(in srgb, var(--cc) 15%, white);
  border-radius: 10px; padding: 10px 14px; line-height: 1.35;
}
.id-group b { font-size: 18px; }
.id-ph {
  width: 130px; height: 100px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.id-ph img { max-width: 100%; max-height: 100%; object-fit: contain; }
.id-emoji { font-size: 62px; }
.id-crits {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px;
}
.crit {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 2px solid color-mix(in srgb, var(--cc) 35%, white);
  font-size: 14px; color: #243447; cursor: pointer; border-radius: 6px 6px 0 0;
  transition: background .12s;
}
.crit:hover { background: color-mix(in srgb, var(--cc) 12%, white); }
.crit input { width: 20px; height: 20px; accent-color: var(--cc); cursor: pointer; }
.crit.good { background: #d7f5e3; }
.crit.bad { background: #fbdede; }
.crit.miss { background: #fdf0d3; }
.id-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.id-check {
  padding: 7px 16px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--cc); color: #fff; font-size: 14px; font-weight: 700;
}
.id-check:hover { filter: brightness(.92); }
.id-result { font-size: 13.5px; font-weight: 700; }
.id-result.ok { color: #1d9e5f; }
.id-result.ko { color: #c2410c; }

.hidden { display: none !important; }

/* ---- Fiches TP ---- */
.activity {
  margin: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel-2); overflow: hidden;
}
.activity > button.head {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 12px 14px; cursor: pointer; font-size: 13.5px;
}
.activity > button.head:hover { background: rgba(56,189,248,.08); }
.activity .body { display: none; padding: 0 14px 12px; font-size: 13px; }
.activity.open .body { display: block; }
.activity h3 { font-size: 12px; color: var(--accent); margin: 8px 0 4px; text-transform: uppercase; }
.activity ul, .activity ol { margin-left: 18px; }
.activity li { margin: 3px 0; }
.badge {
  display: inline-block; font-size: 10.5px; padding: 2px 8px; border-radius: 10px;
  background: rgba(56,189,248,.15); color: var(--accent); margin-right: 6px;
}
.prof-note {
  margin-top: 10px; padding: 10px 12px;
  background: rgba(245,158,11,.12); border-left: 3px solid #f59e0b;
  border-radius: 6px; color: #f0c884; font-size: 12.5px; line-height: 1.5;
}
.prof-note h3 { color: #f59e0b !important; margin: 0 0 4px !important; }
