:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273548;
  --accent: #38bdf8;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
  overflow: hidden; font-size: 14px;
}

/* ---- Toolbar ---- */
#toolbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; }
.logo { font-size: 26px; }
h1 { font-size: 18px; }
.subtitle { font-size: 11px; color: var(--muted); }
.group { display: flex; align-items: center; gap: 6px; }
.group.wrap { flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(56,189,248,.12); }
.chip:hover { filter: brightness(1.15); }

.tb-btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.tb-btn:hover { border-color: var(--accent); }
.tb-btn.on { background: var(--accent); color: #082f49; font-weight: 600; }
.tb-btn:disabled { opacity: .45; cursor: not-allowed; }
.tb-check { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.hidden { display: none !important; }
a.tb-btn { text-decoration: none; }

/* ---- Workspace ---- */
#workspace { display: flex; flex: 1; min-height: 0; }
#canvas-wrap {
  flex: 1; min-width: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, #16202e 0%, var(--bg) 75%);
}
#canvas-wrap canvas { display: block; }

#patron2d {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  padding: 16px;
}
#patron2d svg { max-width: 95%; max-height: 82%; }
#patron2d .cap { font-size: 13px; color: var(--muted); }

/* ---- Panneau latéral ---- */
#sidepanel {
  width: 300px; flex-shrink: 0; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--border);
  padding: 14px; display: flex; flex-direction: column; gap: 16px;
}
#sidepanel h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 8px;
}
.muted { color: var(--muted); }

.stat-grid { display: flex; gap: 8px; }
.stat {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 6px; text-align: center;
}
.stat b { display: block; font-size: 20px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--muted); }
.euler {
  margin-top: 8px; font-size: 12.5px; color: var(--muted);
  background: rgba(56,189,248,.07); border-left: 3px solid var(--accent);
  padding: 6px 8px; border-radius: 0 6px 6px 0; line-height: 1.4;
}

.face-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.face-row .dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }

.aide ul { padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

@media (max-width: 800px) {
  #sidepanel { width: 220px; }
}

/* ---- Quiz solides ---- */
#quiz-panel {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(720px, 92%);
  background: rgba(30,41,59,.96); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
}
#q-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; }
#q-chrono { color: var(--accent); }
#q-score { color: #fbbf24; }
#q-text { font-size: 15px; font-weight: 600; }
#q-options { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.q-opt {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); color: var(--text);
  border: 2px solid var(--border); border-radius: 12px;
  padding: 8px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.q-opt:hover { border-color: var(--accent); }
.q-radio {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted); flex-shrink: 0;
}
.q-opt.net { padding: 6px; }
.q-opt.net .net-svg { width: 150px; height: 120px; background: #f1f5f9; border-radius: 8px; }
.q-opt.good { border-color: #4ade80; background: rgba(74,222,128,.15); }
.q-opt.good .q-radio { border-color: #4ade80; background: #4ade80; }
.q-opt.bad { border-color: #f87171; background: rgba(248,113,113,.15); }
.q-opt.bad .q-radio { border-color: #f87171; background: #f87171; }
#q-result { font-size: 14px; font-weight: 600; min-height: 18px; text-align: center; }
#q-result .final { font-size: 18px; padding: 4px 0; }

/* ---- Sidebar Activités ---- */
#workspace { position: relative; }
#sidebar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: min(360px, 92vw); z-index: 20;
  background: var(--panel); border-right: 1px solid var(--border);
  overflow-y: auto;
  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; }
#toggle-sidebar.active { background: var(--accent); color: #082f49; font-weight: 600; }

.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: 10px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.activity > button.head:hover { background: rgba(56,189,248,.08); }
.activity.open > button.head { border-bottom: 1px solid var(--border); }
.tp-num {
  background: var(--accent); color: #082f49; font-weight: 700;
  font-size: 12px; border-radius: 6px; padding: 3px 7px; flex-shrink: 0;
}
.tp-title { flex: 1; font-size: 14px; font-weight: 600; }
.tp-level { font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.activity .body { display: none; padding: 10px 14px 14px; font-size: 13px; line-height: 1.5; }
.activity.open .body { display: block; }
.body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); margin: 10px 0 4px; }
.body h3:first-child { margin-top: 0; }
.body ol { padding-left: 18px; }
.body li { margin: 3px 0; }
.body .question {
  background: rgba(251,191,36,.08); border-left: 3px solid #fbbf24;
  padding: 5px 8px; margin: 4px 0; border-radius: 0 6px 6px 0;
}

/* Note enseignant dans les fiches TP */
.prof-note { margin-top: 12px; background: rgba(245,158,11,.10);
  border-left: 3px solid #f59e0b; border-radius: 8px; padding: 8px 10px; }
.prof-note h3 { color: #fbbf24; }
.prof-note p { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
