:root {
  --bg: #0c0d10;
  --panel: #14161b;
  --panel-2: #1a1c22;
  --border: #23262e;
  --text: #d8dadf;
  --muted: #6e727c;
  --accent: #ffae3a;
  --accent-2: #6ec1ff;
  --pos: #5fd49a;
  --neg: #ff6b6b;
  --warn: #ffc14d;
  --mono: ui-monospace, "JetBrains Mono", "Consolas", "Menlo", monospace;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- Banner d'etat synthetique ---- */
.state-banner {
  position: sticky;
  top: 47px; /* sous .bar */
  z-index: 4;
  background: linear-gradient(180deg, #1a1812 0%, #161821 100%);
  border-bottom: 1px solid var(--border);
  padding: 8px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: help;
}
.state-banner.alert {
  background: linear-gradient(180deg, #2a1a1c 0%, #1f1719 100%);
  border-bottom-color: #4a2a2c;
}
.state-banner.warn {
  background: linear-gradient(180deg, #221c12 0%, #1a1a17 100%);
  border-bottom-color: #4a3c1a;
}
.banner-headline {
  font-size: 13px;
  color: #e8e3d2;
  line-height: 1.4;
}
.banner-headline b { color: var(--accent); font-weight: 600; }
.banner-headline .since { color: var(--accent-2); font-family: var(--mono); font-size: 11.5px; }
.banner-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.banner-signals .sig {
  background: #20232b;
  border: 1px solid #2b2f39;
  border-radius: 10px;
  padding: 1px 8px;
}
.banner-signals .sig.active { background: #2a1a1c; border-color: #4a2a2c; color: #ffb1b1; }
.banner-signals .sig.warn   { background: #221c12; border-color: #4a3c1a; color: #ffd089; }
.banner-signals .sig.good   { background: #15201a; border-color: #2a4a3a; color: #9bdcb6; }

/* duree a cote des labels (kv label + hero mode) */
.dur {
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 10.5px;
  margin-left: 6px;
  font-weight: normal;
}

/* count "× N" pour les pensees recurrentes */
.thought-count {
  background: var(--accent);
  color: #1a1812;
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}
.thought-first {
  color: var(--muted);
  font-size: 10px;
  margin-left: 6px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, #14161b, #0f1115);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { font-size: 15px; letter-spacing: 0.3px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #444; transition: background 0.3s, box-shadow 0.3s;
}
.dot.live { background: var(--pos); box-shadow: 0 0 10px rgba(95, 212, 154, 0.7); }
.dot.stale { background: var(--warn); box-shadow: 0 0 10px rgba(255, 193, 77, 0.5); }
.dot.dead { background: var(--neg); box-shadow: 0 0 10px rgba(255, 107, 107, 0.6); }

.muted { color: var(--muted); }
.small { font-size: 11.5px; }

.bar-right { display: flex; align-items: center; gap: 18px; }
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #14161b;
}
.nav-btn {
  background: #181a20;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-btn:hover { color: var(--accent); border-color: var(--accent); }
.nav-btn.active { background: #25272e; color: var(--accent); border-color: var(--accent); font-weight: 600; }

.range-picker {
  display: inline-flex;
  background: #181a20;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 0;
}
.range-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.range-btn:hover { color: var(--text); }
.range-btn.active {
  background: #25272e;
  color: var(--accent);
  font-weight: 600;
}

.mode-pill {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
}
.mode-pill #bar-mode { color: var(--accent); font-weight: 600; }
.mode-pill #bar-tick { color: var(--accent-2); }

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card h3 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #b9bcc4;
}
.card h4 { margin: 0; font-size: 11px; font-weight: 500; }
.card .mt { margin-top: 10px; }
.span2 { grid-column: span 2; }

.hero { grid-column: span 2; flex-direction: row; gap: 24px; align-items: stretch; }
.hero-mode {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border);
  padding-right: 16px;
}
.hero-mode-name {
  font-size: 38px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin: 4px 0;
}
.hero-intention { font-size: 13px; }
.hero-intention span { color: var(--text); font-family: var(--mono); }

.gauges {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 22px;
  align-content: center;
}
.gauge { display: flex; flex-direction: column; gap: 4px; }
.gauge-track {
  position: relative;
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}
.gauge-fill {
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 0%;
  background: var(--accent-2);
  transition: width .12s linear, background .25s;
}
.gauge-fill.warm { background: linear-gradient(90deg, #ffae3a, #ff6b6b); }
.gauge-fill.bipolar {
  left: 50%;
  transform-origin: left;
  background: var(--neg);
}
.gauge-fill.bipolar.pos {
  background: var(--pos);
}
.gauge-val { font-family: var(--mono); font-size: 16px; }

.kv { list-style: none; padding: 0; margin: 0; }
.kv li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed #1f2229;
  font-size: 13px;
}
.kv li:last-child { border-bottom: 0; }

/* ---- value with delta arrow ---- */
.vd {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  cursor: help;
}
.vd .arrow {
  font-style: normal;
  font-size: 10px;
  width: 10px;
  display: inline-block;
  text-align: center;
  opacity: 0.85;
}
.vd.flat .arrow { color: #4c4f57; }
.vd.up   .arrow { color: var(--pos); }
.vd.down .arrow { color: var(--neg); }
.vd.flat .arrow::before { content: '→'; }
.vd.up   .arrow::before { content: '↑'; }
.vd.down .arrow::before { content: '↓'; }

.vd .mini-spark {
  width: 56px;
  height: 12px;
  vertical-align: middle;
  display: inline-block;
  opacity: 0.85;
}
.vd .mini-spark polyline {
  fill: none;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.vd.flat .mini-spark polyline { stroke: #6e727c; }
.vd.up   .mini-spark polyline { stroke: var(--pos); }
.vd.down .mini-spark polyline { stroke: var(--neg); }
.vd .mini-spark .zero { stroke: #2a2d35; stroke-width: 1; stroke-dasharray: 1.5,2; }

.tooltip {
  position: fixed;
  background: #0a0c10;
  border: 1px solid #2b2f3a;
  color: var(--text);
  padding: 8px 11px;
  border-radius: 5px;
  font-size: 11.5px;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0,0,0,0.55);
  max-width: 320px;
  line-height: 1.45;
}
.tooltip .tt-name  { font-weight: 600; color: var(--accent); font-size: 12px; margin-bottom: 2px; letter-spacing: 0.2px; }
.tooltip .tt-desc  { color: #c5c8d0; margin-bottom: 4px; }
.tooltip .tt-scale { color: var(--muted); font-style: italic; font-size: 10.5px; margin-bottom: 6px; }
.tooltip .tt-divider { height: 1px; background: #1f2229; margin: 5px 0; }
.tooltip .tt-meta  { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.tooltip .tt-meta b { color: var(--text); font-weight: 500; }
.tooltip .tt-interpret {
  color: #e8e3d2;
  background: #1a1812;
  border-left: 2px solid var(--accent);
  padding: 4px 7px;
  margin: 4px 0;
  border-radius: 3px;
  font-size: 11px;
  font-style: italic;
}
.tooltip .tt-interpret b { font-style: normal; font-weight: 500; color: var(--accent); }
.tooltip .tt-delta.up   { color: var(--pos); }
.tooltip .tt-delta.down { color: var(--neg); }
.tooltip .tt-delta.flat { color: #6e727c; }

/* Marque les valeurs textuelles cliquables-explicables */
.vt {
  cursor: help;
  border-bottom: 1px dotted #3a3d46;
}
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); }
.kv .v.dim { color: var(--muted); }
.kv .v.warn { color: var(--warn); }
.kv .v.bad { color: var(--neg); }
.kv .v.good { color: var(--pos); }

.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 50px; align-items: center; gap: 8px; }
.bar-row .name { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.bar-row .track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); transition: width .12s linear; }
.bar-row .num { font-family: var(--mono); font-size: 12px; text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.chip {
  background: #20232b;
  border: 1px solid #2b2f39;
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 11px;
  color: #c8cad0;
  font-family: var(--mono);
}

.patho-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.patho-cell {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 8px 10px;
  border-left: 3px solid var(--border);
}
.patho-cell.active { border-left-color: var(--neg); background: #2a1a1c; }
.patho-cell .label { font-size: 11px; color: var(--muted); }
.patho-cell .val { font-size: 16px; font-family: var(--mono); }

.thought {
  font-size: 16px;
  font-style: italic;
  color: #e8e3d2;
  background: #1a1812;
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 4px;
  font-family: Georgia, serif;
}
.thought-log {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
}
.thought-log li {
  padding: 4px 0;
  border-bottom: 1px dashed #1f2229;
  font-size: 12px;
  color: #c0c2c8;
  display: flex;
  gap: 10px;
}
.thought-log .ts { color: var(--muted); font-family: var(--mono); flex: 0 0 60px; }
.thought-log .lvl { color: var(--accent-2); font-family: var(--mono); flex: 0 0 60px; font-size: 11px; }

.transition-log {
  list-style: none;
  padding: 0;
  margin: 0;
}
.transition-log li {
  padding: 6px 0;
  border-bottom: 1px solid #1f2229;
  font-family: var(--mono);
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.transition-log .ts { color: var(--muted); flex: 0 0 70px; }
.transition-log .arrow { color: var(--accent); }
.transition-log .from { color: var(--muted); }
.transition-log .to { color: var(--accent); font-weight: 600; }

/* ---- Harmonie ---- */
.harmony-meter {
  position: relative;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
}
.harmony-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  background: linear-gradient(90deg, #b87afa 0%, #6ec1ff 60%, #5fd49a 100%);
  transition: width .12s linear;
}
.dissonance-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* min-height : reserve l'espace pour 10 items (les regles sont stables, evite tout saut visuel) */
  min-height: 480px;
}
.dissonance-list li {
  background: linear-gradient(90deg, #1c1730, #181f2c);
  border-left: 3px solid #b87afa;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dissonance-list li.consonant {
  background: #15201a;
  border-left-color: #5fd49a;
  opacity: 0.65;
}
.dissonance-list .pair { font-family: var(--mono); color: #d4c4f5; font-size: 11px; letter-spacing: 0.3px; }
.dissonance-list li.consonant .pair { color: #8ec9a8; }
.dissonance-list .hint { color: #c0c2c8; }
.dissonance-list .empty { color: var(--muted); font-style: italic; padding: 8px; }

/* ---- Mouvements (partition) ---- */
.movements {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.movement {
  display: grid;
  grid-template-columns: 88px 70px 80px 1fr;
  gap: 12px;
  align-items: center;
  padding: 7px 10px;
  background: var(--panel-2);
  border-left: 3px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}
.movement.current { border-left-color: var(--accent); background: linear-gradient(90deg, #221a10, #1a1c22); }
.movement .mvt-mode { font-family: var(--mono); color: var(--accent); font-weight: 600; font-size: 13px; }
.movement .mvt-dur  { font-family: var(--mono); color: var(--accent-2); }
.movement .mvt-time { font-family: var(--mono); color: var(--muted); font-size: 11px; }
.movement .mvt-sig  { display: flex; gap: 14px; flex-wrap: wrap; }
.movement .mvt-sig span { color: #9da0a8; }
.movement .mvt-sig b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.movement .mvt-tone { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

.spark-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.spark {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 6px 8px;
}
.spark .label { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.spark .label .last { color: var(--text); font-family: var(--mono); }
.spark svg { width: 100%; height: 36px; display: block; margin-top: 2px; }

@media (max-width: 1280px) { .grid { grid-template-columns: repeat(3, 1fr); } .hero { grid-column: span 3; } .span2 { grid-column: span 2; } .spark-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } .hero { grid-column: span 2; flex-direction: column; } .hero-mode { border-right: 0; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; flex: 0 0 auto; } .span2 { grid-column: span 2; } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } .hero, .span2 { grid-column: span 1; } .gauges { grid-template-columns: 1fr; } .spark-grid { grid-template-columns: 1fr; } }
