:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #ececf2;
  --border: #d8d8e0;
  --text: #1a1a2e;
  --text-dim: #6a6a7a;
  --accent: #6d3fb0;
  --accent2: #5830a0;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --blue: #2563eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.5px;
}

nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  transition: all 0.2s;
  cursor: pointer;
}

nav a:hover, nav a.active {
  color: var(--text);
  background: var(--surface2);
}

nav a.nav-limites {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 5px;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
nav a.nav-limites:hover, nav a.nav-limites.active {
  background: var(--surface2);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.section { display: none; }
.section.active { display: block; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--accent); }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

/* Tableau 20 lignes */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover { background: rgba(109, 63, 176, 0.05); }

.badge-sd {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

.theta-bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  width: 140px;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.theta-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  
}

/* Radar */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  min-height: 500px;
  height: 70vh;
  margin: 0 auto 2rem;
}

/* Exercice */
.exercice-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 700px;
  margin: 0 auto;
}

.pick-line {
  margin-bottom: 1.5rem;
}

.pick-line select {
  width: 100%;
  padding: 0.6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.95rem;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover { background: var(--accent2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-box {
  margin-top: 1.5rem;
}

.chat-messages {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.chat-msg {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.thinking {
  text-align: center;
  padding: 1.5rem;
  font-style: italic;
  font-size: 1.1rem;
  font-weight: 500;
  animation: thinkingPulse 2s ease-in-out infinite;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

@keyframes thinkingPulse {
  0%   { color: #8b3fe0; border-color: rgba(139, 63, 224, 0.25); box-shadow: 0 0 8px rgba(139, 63, 224, 0.08); }
  20%  { color: #dc2626; border-color: rgba(220, 38, 38, 0.25); box-shadow: 0 0 12px rgba(220, 38, 38, 0.1); }
  40%  { color: #2563eb; border-color: rgba(37, 99, 235, 0.25); box-shadow: 0 0 12px rgba(37, 99, 235, 0.1); }
  60%  { color: #ea580c; border-color: rgba(234, 88, 12, 0.25); box-shadow: 0 0 12px rgba(234, 88, 12, 0.1); }
  80%  { color: #16a34a; border-color: rgba(22, 163, 74, 0.25); box-shadow: 0 0 12px rgba(22, 163, 74, 0.1); }
  100% { color: #8b3fe0; border-color: rgba(139, 63, 224, 0.25); box-shadow: 0 0 8px rgba(139, 63, 224, 0.08); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.chat-msg.ia {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
}

.chat-msg.user {
  background: rgba(37, 99, 235, 0.08);
  border-left: 3px solid var(--blue);
  text-align: right;
}

.chat-msg .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
}

.chat-input textarea {
  flex: 1;
  padding: 0.6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.qcm-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.qcm-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.4;
}

.qcm-option:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.atrous-block {
  margin-top: 0.5rem;
  line-height: 2.4;
  word-break: break-word;
}

.atrous-block span {
  margin: 0 0.1rem;
}

.atrous-blank {
  min-width: 8rem;
  padding: 0.3rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.atrous-blank:focus {
  outline: none;
  border-color: var(--accent);
}

.atrous-envoyer {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.4;
}

.atrous-envoyer:hover {
  background: var(--accent);
  color: #fff;
}

.atrous-envoyer:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


  width: 16px;
  height: 16px;
  border: 2px solid rgba(109, 63, 176, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;


.loading::after {
  content: "...";
  animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots { 0%,20% { content: "."; } 40% { content: ".."; } 60%,100% { content: "..."; } }


/* Legende SD */
.sd-legend {
  margin: 1rem 0;
}
.sd-legend table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 6px;
  overflow: hidden;
}
.sd-legend td {
  border: none;
}

/* Section moyenne humanite */
.avg-section {
  background: rgba(13, 148, 136, 0.04);
  border: 1px solid rgba(13, 148, 136, 0.15);
  border-left: 3px solid #0d9488;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
}
.avg-section .chart-wrap {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
}

/* Score feedback */
.score-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 1rem;
}

.score-badge.high { background: rgba(22, 163, 74, 0.15); color: var(--green); }
.score-badge.med { background: rgba(234, 88, 12, 0.15); color: var(--orange); }
.score-badge.low { background: rgba(220, 38, 38, 0.15); color: var(--red); }

@media (max-width: 768px) {
  .container { padding: 0.75rem; }
  table { font-size: 0.75rem; }
  th, td { padding: 0.35rem 0.5rem; }
}
/* Cadran grid */
.cadran-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.cadran-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.cadran-card:nth-child(2n+1) {
  border-left: 3px solid var(--accent);
}
.cadran-card:nth-child(2n) {
  border-left: 3px solid var(--accent2);
}
.cadran-card-title {  font-size: 1rem;  font-weight: 700;  color: var(--accent);  margin: 0 0 0.75rem;  text-align: center;  line-height: 1.3;  padding-bottom: 0.5rem;  border-bottom: 1px solid var(--border);}
.cadran-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cadran-card th {
  display: none;
}
.cadran-card td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.cadran-card tbody tr:hover { background: rgba(109, 63, 176, 0.08); }
.cadran-card tr:last-child td {
  border-bottom: none;
}
.tc-num {
  font-weight: 700;
  font-size: 0.7rem;
  width: 2rem;
  text-align: center;
  color: var(--text-dim);
}
.tc-ligne {
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.tc-prog {
  min-width: 80px;
}
.tc-sess {
  text-align: center;
  width: 2.5rem;
  font-size: 0.7rem;
  color: var(--text-dim);
}
@media (max-width: 768px) {
  .cadran-grid { grid-template-columns: 1fr; }
}

/* Mini-questionnaire de ressenti (fin d'exercice) */
.ressenti-box {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ressenti-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.ressenti-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.ressenti-option {
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.3;
}

.ressenti-option:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ressenti-option.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ressenti-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.ressenti-home,
.ressenti-go {
  padding: 0.4rem 0.7rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.3;
}

.ressenti-home:hover,
.ressenti-go:hover {
  color: #fff;
}

.ressenti-ligne-select {
  padding: 0.4rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.8;
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}
