: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; flex-wrap: wrap; }

.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; }
a.tb-btn { text-decoration: none; }
.hidden { display: none !important; }

/* ---- Workspace ---- */
#workspace { display: flex; flex: 1; min-height: 0; }
#stage {
  flex: 1; min-width: 0; display: flex;
  align-items: center; justify-content: center;
  padding: 16px; overflow: auto;
  background: radial-gradient(circle at 50% 30%, #16202e 0%, var(--bg) 75%);
}
#eau-svg { width: 100%; max-width: 860px; max-height: 100%; border-radius: 12px; }

/* Étiquettes du décor */
.lbl {
  font-size: 15px; font-weight: 700; fill: #1c3d5a;
  text-anchor: middle; paint-order: stroke;
  stroke: rgba(255,255,255,.75); stroke-width: 4px;
  pointer-events: none;
}
.lbl.white { fill: #fff; stroke: rgba(15,60,90,.8); }

/* Zones cliquables du décor eau */
.hot { cursor: pointer; }
.hot:hover { filter: brightness(1.15) drop-shadow(0 0 8px #38bdf8); }
.hot.sel { filter: brightness(1.2) drop-shadow(0 0 12px #38bdf8); }
.hot.good { filter: drop-shadow(0 0 14px #4ade80) brightness(1.4); }
.hot.bad { filter: drop-shadow(0 0 14px #ef4444) brightness(1.4); }

/* Animations du décor */
.rays { animation: spin 24s linear infinite; transform-origin: 90px 80px; }
@keyframes spin { to { transform: rotate(360deg); } }

.cloud { animation: drift 14s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(90px); } }

.evap path { animation: rise 2.6s ease-in-out infinite; }
.evap path:nth-child(2) { animation-delay: .8s; }
.evap path:nth-child(3) { animation-delay: 1.6s; }
@keyframes rise { 0%,100% { opacity:.25; transform:translateY(14px);} 50% { opacity:1; transform:translateY(-14px);} }

.rain line { animation: fall 1.3s linear infinite; }
.rain line:nth-child(2) { animation-delay: .3s; }
.rain line:nth-child(3) { animation-delay: .6s; }
.rain line:nth-child(4) { animation-delay: .9s; }
@keyframes fall { 0% { opacity:0; transform:translateY(0);} 30% {opacity:1;} 100% { opacity:0; transform:translateY(70px);} }

.river { stroke-dasharray: 18 14; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -32; } }

.waves { animation: wave 4s ease-in-out infinite alternate; }
@keyframes wave { from { transform: translateX(-18px); } to { transform: translateX(18px); } }

/* ---- Cartes étapes (animaux) ---- */
.cycle-loop {
  display: flex; align-items: stretch; justify-content: center;
  gap: 12px; flex-wrap: wrap; max-width: 900px;
}
.step-card {
  width: 170px; background: var(--panel); border: 2px solid var(--border);
  border-radius: 12px; padding: 14px; text-align: center; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.step-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.step-card.sel { border-color: var(--accent); box-shadow: 0 0 14px rgba(56,189,248,.45); }
.step-card.good { border-color: #4ade80; box-shadow: 0 0 14px #4ade80; }
.step-card.bad { border-color: #ef4444; box-shadow: 0 0 14px #ef4444; }
.step-n {
  display: inline-block; background: var(--accent); color: #082f49;
  font-weight: 700; border-radius: 999px; padding: 1px 9px; font-size: 12px;
}
.step-icon { font-size: 44px; margin: 8px 0; }
.step-img {
  width: 100%; height: 100px; object-fit: cover;
  border-radius: 8px; margin: 8px 0;
}
.step-nom { font-weight: 700; margin-bottom: 6px; }
.step-card p { font-size: 12px; color: var(--muted); line-height: 1.4; }
.step-arrow {
  align-self: center; font-size: 26px; color: var(--accent);
}
.step-arrow.loop-end { font-size: 15px; color: var(--muted); width: 100%; text-align: center; }

/* ---- 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;
}
#cycle-info h4, #quiz-box h4 { font-size: 16px; margin-bottom: 8px; }
#cycle-info p, #quiz-box p { line-height: 1.5; }
.mini { font-size: 12px; color: var(--muted); }
.funfact {
  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-box {
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px;
}
.aide ul { padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

@media (max-width: 800px) {
  #sidepanel { width: 230px; }
  .step-card { width: 140px; }
}
