/* Théorème de Pythagore en images */
* { box-sizing: border-box; }
:root { --ca: #2563eb; --cb: #16a34a; --cc: #ea580c; --accent: #15803d; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: #f0fdf4; color: #1f2937; }
.hidden { display: none !important; }

header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 18px; color: #fff; background: linear-gradient(135deg, #15803d, #0d9488);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 1 1 280px; min-width: 0; }
.brand > div { min-width: 0; }
.brand .logo { font-size: 2rem; }
.brand h1 { margin: 0; font-size: 1.35rem; }
.brand .subtitle { margin: 0; font-size: .85rem; opacity: .92; }
nav { display: flex; gap: 8px; }
.nav-btn {
  background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,.32); }

.layout { display: flex; min-height: calc(100vh - 60px); }
#sidebar { width: 330px; flex: 0 0 330px; background: #fff; border-right: 1px solid #e5e7eb; padding: 14px; overflow-y: auto; }
#sidebar.hidden { display: none !important; }
.sidebar-head h2 { margin: 0 0 4px; font-size: 1.1rem; }
.sidebar-head .hint { margin: 0 0 10px; font-size: .85rem; color: #6b7280; }
.activity { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.activity .head { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: #f0fdf4; border: 0; cursor: pointer; text-align: left; font: inherit; font-size: .9rem; }
.activity .head:hover { background: #dcfce7; }
.activity .tp-num { background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: .75rem; font-weight: 700; }
.activity .tp-title { flex: 1; font-weight: 600; }
.activity .tp-level { font-size: .75rem; color: #6b7280; white-space: nowrap; }
.activity .body { display: none; padding: 10px 12px; font-size: .88rem; border-top: 1px solid #e5e7eb; }
.activity.open .body { display: block; }
.activity .body h3 { font-size: .8rem; text-transform: uppercase; color: var(--accent); margin: 10px 0 4px; }
.activity .body ol { margin: 4px 0; padding-left: 20px; }
.activity .body li { margin-bottom: 3px; }
.activity .question { background: #f0fdf4; border-left: 3px solid #4ade80; padding: 5px 8px; margin: 5px 0; border-radius: 0 6px 6px 0; }
.activity .prof-note { background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; padding: 4px 10px 8px; margin-top: 10px; }

#main { flex: 1; min-width: 0; padding: 16px; max-width: 1200px; margin: 0 auto; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab { border: 2px solid #bbf7d0; background: #fff; color: #166534; border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }
.lbl { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 6px; }
.ca { color: var(--ca); } .cb { color: var(--cb); } .cc { color: var(--cc); }

.see-grid { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 14px; align-items: start; }
.controls .ctrl { margin-bottom: 14px; }
.controls label { font-weight: 700; display: block; margin-bottom: 4px; }
.controls output { font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { font-weight: 600 !important; display: flex !important; gap: 8px; align-items: center; }
.intro { margin-top: 0; line-height: 1.5; }
.figure-card { padding: 6px; }
.figure-card svg { width: 100%; height: auto; display: block; max-height: 74vh; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid #bbf7d0; background: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; color: #14532d; }
.chip:hover { background: #f0fdf4; }
.chip.active { border-color: var(--accent); background: #dcfce7; font-weight: 700; }
.btn { background: var(--accent); color: #fff; border: 2px solid var(--accent); border-radius: 10px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { background: #166534; }
.btn.ghost { background: #fff; color: #166534; border-color: #86efac; }
.btn.ghost:hover { background: #f0fdf4; }
.btn.small { padding: 4px 10px; font-size: .85rem; margin-top: 6px; }
.btn.big { width: 100%; font-size: 1.1rem; padding: 12px; }


/* ---- Atelier aire et périmètre ---- */
.ga { color: #15803d; font-weight: 800; }
.gp { color: #dc2626; font-weight: 800; }
.subtitle .ga, .subtitle .gp { color: #fff; text-decoration: underline; text-decoration-thickness: 3px; }
.subtitle .ga { text-decoration-color: #86efac; }
.subtitle .gp { text-decoration-color: #fca5a5; }
.muted { color: #6b7280; }
.small { font-size: .88rem; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.lvl { border: 2px solid #bbf7d0; background: #fff; border-radius: 12px; padding: 6px 12px; font: inherit; font-weight: 700; cursor: pointer; color: #166534; text-align: left; }
.lvl small { display: block; font-weight: 500; color: #6b7280; font-size: .78rem; }
.lvl.active { background: #15803d; border-color: #15803d; color: #fff; }
.lvl.active small { color: #dcfce7; }
.two { display: grid; grid-template-columns: minmax(280px, 1.3fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.fig-wrap { text-align: center; }
.fig-wrap svg.fig { width: 100%; max-height: 62vh; height: auto; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair svg.fig { max-height: 44vh; }
.answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; font-size: 1.1rem; font-weight: 700; }
.answer-row label { min-width: 6.5em; }
.answer-row input { width: 110px; font-size: 1.3rem; font-weight: 800; text-align: center; border: 2px solid #cbd5e1; border-radius: 10px; padding: 4px; }
.answer-row input:focus { outline: none; border-color: var(--accent); }
.answer-row input.ok { border-color: #16a34a; background: #f0fdf4; }
.answer-row input.ko { border-color: #dc2626; background: #fef2f2; }
.feed { display: block; min-height: 1.6em; margin-top: 10px; font-weight: 600; line-height: 1.6; }
.feed.good { color: #15803d; } .feed.bad { color: #b91c1c; }
.feed.info { color: #1f2937; font-weight: 500; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px 12px; }
.feed.info p { margin: 4px 0; }
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.radios { display: flex; gap: 14px; margin-top: 6px; }
.radios label { display: flex; gap: 5px; align-items: center; font-weight: 600; cursor: pointer; }
.chal { display: flex; gap: 10px; align-items: flex-start; background: #fefce8; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; font-size: 1.08rem; }
.chal-ico { font-size: 1.5rem; }
.model svg.fig { width: 180px; max-height: 140px; }
.meter { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; padding: 6px 12px; font-size: 1.05rem; }
.s-count { font-weight: 700; color: #166534; margin-bottom: 4px; }
.s-q { font-size: 1.2rem; margin: 6px 0; }
#s-box svg.fig { max-height: 42vh; }
#s-box .pair svg.fig { max-height: 36vh; }
.s-end { text-align: center; padding: 10px; }
.s-score { font-size: 3rem; font-weight: 800; color: #166534; }
.s-stars { font-size: 2rem; }

/* SVG */
svg text { font-family: "Segoe UI", system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; }
svg .grid line { stroke: #cbd5e1; stroke-width: 1; }
svg .fill { fill: #e0e7ff; }
svg .fill.see { fill: rgba(99, 102, 241, .18); }
svg .fill.rev { fill: #f0fdf4; }
svg .edge { fill: none; stroke: #1e293b; stroke-width: 3.5; stroke-linejoin: round; }
svg .edge.rev { stroke: #dc2626; stroke-width: 6; }
svg .tile { fill: #4ade80; stroke: #15803d; stroke-width: 1; }
svg .tnum { font-size: 15px; font-weight: 700; fill: #14532d; }
svg .ebadge { fill: #fff; stroke: #dc2626; stroke-width: 2; }
svg .enum { font-size: 12px; font-weight: 800; fill: #b91c1c; }
svg .len { font-size: 17px; font-weight: 800; fill: #1e293b; }
svg .letter { font-size: 26px; font-weight: 800; fill: #166534; }
svg .part { stroke: #15803d; stroke-width: 2; stroke-dasharray: 6 4; }
svg .part.p0 { fill: #86efac; } svg .part.p1 { fill: #bbf7d0; }
svg .pnum { font-size: 17px; font-weight: 800; fill: #14532d; }
.fig-wrap svg.fig.build { touch-action: none; cursor: pointer; width: auto; max-width: 100%; height: min(48vh, 480px); max-height: none; }
svg .bcell { fill: #fff; stroke: #cbd5e1; stroke-width: 1; }
svg .bcell:hover { fill: #f0fdf4; }
svg .bcell.on { fill: #4ade80; stroke: #15803d; }

/* Projeter (TBI) */
body.project { font-size: 1.25rem; }
body.project #sidebar { display: none !important; }
body.project .fig-wrap svg.fig { max-height: 72vh; }

@media (max-width: 860px) {
  .two, .qgrid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  #sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid #e5e7eb; max-height: 45vh; }
  .brand h1 { font-size: 1.1rem; }
  #main { padding: 10px; }
  nav { flex-wrap: wrap; }
}
@media (max-width: 520px) { .pair { grid-template-columns: 1fr; } }
