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

* { 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: currentColor; }
.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-check { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.hidden { display: none !important; }

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

/* ---- Vue photographie réelle ---- */
#photo-wrap {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 12px; min-height: 0; min-width: 0;
  flex: 1; align-self: stretch;
}
#photo-stage { position: relative; }
#photo-reelle {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 10px; background: #fff;
  box-shadow: 0 6px 30px rgba(0,0,0,.55);
}
#photo-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.photo-spot ellipse {
  fill: transparent; stroke: rgba(255,255,255,.30);
  stroke-width: 4; stroke-dasharray: 12 8;
}
.photo-spot:hover ellipse { fill: rgba(56,189,248,.20); stroke: var(--accent); }
.photo-spot.flash-ok ellipse { stroke: #4ade80; fill: rgba(74,222,128,.35); }
.photo-spot.flash-ko ellipse { stroke: #ef4444; fill: rgba(239,68,68,.35); }
.photo-label {
  font-size: 30px; fill: #fff;
  paint-order: stroke; stroke: rgba(15,23,42,.85); stroke-width: 7px;
}
#photo-credit { font-size: 11px; color: var(--muted); }

/* ---- Vue atlas 3D (iframe Sketchfab) ---- */
#atlas3d-wrap {
  display: flex; flex-direction: column;
  gap: 8px; padding: 12px; min-height: 0; min-width: 0;
  flex: 1; align-self: stretch;
}
#atlas3d {
  flex: 1; width: 100%; min-height: 0;
  border: 0; border-radius: 10px;
  box-shadow: 0 6px 30px rgba(0,0,0,.55);
}
#atlas3d-credit { font-size: 11px; color: var(--muted); }

/* Silhouette */
.silhouette > * {
  fill: var(--body); stroke: #7f9bb8; stroke-width: 2.5; stroke-linejoin: round;
  transition: fill .3s, opacity .3s;
}
#corps.solo .silhouette > * { fill: #1b2738; stroke: #a5bdd6; }
.chip-tous { font-weight: 600; }
.chip.solo { background: var(--panel-2); box-shadow: 0 0 0 2px currentColor inset; }

/* Organes */
.sys-layer .fill { fill: currentColor; }
.sys-layer .stroke { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.sys-layer .stroke.thick { stroke-width: 6; }
.sys-layer .stroke.thin { stroke-width: 1.5; }
.sys-layer .stroke.art { stroke: #ef4444; stroke-width: 3; }
.sys-layer .stroke.vein { stroke: #60a5fa; stroke-width: 3; }
.sys-layer .coeur-shape { fill: #ef4444; }

.organ { cursor: pointer; transition: filter .15s; }
.organ:hover { filter: drop-shadow(0 0 7px currentColor) brightness(1.3); }
.organ.flash-ok { filter: drop-shadow(0 0 10px #4ade80) brightness(1.6); }
.organ.flash-ko { filter: drop-shadow(0 0 10px #ef4444) brightness(1.6); }

.org-label {
  fill: #e2e8f0; font-size: 11px;
  paint-order: stroke; stroke: #0f172a; stroke-width: 3px;
}

/* ---- 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); }

.info-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.info-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.info-head .dot { width: 12px; height: 12px; border-radius: 50%; }
.info-sys { font-size: 11px; color: var(--muted); margin: 4px 0 8px; text-transform: uppercase; letter-spacing: .05em; }
.info-card p { line-height: 1.45; }
.info-fact {
  margin-top: 10px; font-size: 12.5px; line-height: 1.4;
  background: rgba(251,191,36,.08); border-left: 3px solid #fbbf24;
  padding: 6px 8px; border-radius: 0 6px 6px 0;
}

.quiz-q { font-size: 15px; margin-bottom: 8px; }
.quiz-q strong { color: var(--accent); }
.quiz-score { color: var(--muted); font-size: 13px; }

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

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

a.tb-btn { text-decoration: none; }
