:root {
  --bg: #0d0d1a;
  --surface: #16162a;
  --surface2: #1e1e38;
  --border: #2a2a50;
  --accent: #7c6fcd;
  --accent2: #cd7c6f;
  --narrator-active: #22224a;
  --narrator-text: #8899ff;
  --dialogue-active: #1e3828;
  --dialogue-text: #6ecf88;
  --text: #d0d0ee;
  --text-muted: #7777aa;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Georgia', serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
}
.logo { font-size: 1.2rem; font-weight: bold; letter-spacing: 1px; }
.logo .v1 { color: var(--narrator-text); }
.logo .v2 { color: var(--dialogue-text); }
.btn-open {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: sans-serif;
  white-space: nowrap;
}
#fileInput { display: none; }

/* SCREENS */
#uploadScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 24px;
  text-align: center;
}
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 20px;
  padding: 44px 28px;
  width: 100%;
  max-width: 340px;
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.drag-over { border-color: var(--accent); background: var(--surface); }
.drop-icon { font-size: 3.5rem; margin-bottom: 14px; }
.drop-title { font-size: 1.3rem; margin-bottom: 6px; font-weight: bold; }
.drop-sub { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }
.btn-big {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 30px;
  border-radius: 24px;
  font-size: 1rem;
  cursor: pointer;
  font-family: sans-serif;
}
.legend {
  margin-top: 24px;
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 18px;
  text-align: left;
  width: 100%;
  max-width: 340px;
  font-family: sans-serif;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.8;
}
.legend strong { color: var(--text); }

#loadingScreen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  gap: 16px;
}
.spinner {
  width: 50px; height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.load-txt { font-family: sans-serif; color: var(--text-muted); font-size: 0.9rem; }

#readerScreen { display: none; }

/* CHAPTER BAR */
.chapter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chapter-bar label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: sans-serif;
  white-space: nowrap;
}
#chapterSelect {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-family: sans-serif;
}

/* TEXT DISPLAY */
#textDisplay {
  padding: 16px 14px 260px;
  line-height: 1.75;
  font-size: 1.02rem;
}
.seg {
  padding: 7px 12px;
  border-radius: 9px;
  margin-bottom: 3px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.seg.narration { color: var(--text); }
.seg.narration:hover { background: #1a1a30; }
.seg.narration.active {
  background: var(--narrator-active);
  border-left-color: var(--narrator-text);
  color: #c8d4ff;
}
.seg.dialogue { color: #aae0bb; font-style: italic; }
.seg.dialogue:hover { background: #182820; }
.seg.dialogue.active {
  background: var(--dialogue-active);
  border-left-color: var(--dialogue-text);
  color: #b0ffcc;
}
.seg-icon {
  display: inline-block;
  font-style: normal;
  font-size: 0.72rem;
  margin-right: 5px;
  opacity: 0.6;
  vertical-align: middle;
}

/* PLAYER */
#player {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 150;
}
.progress-wrap {
  height: 3px;
  background: var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--narrator-text), var(--accent));
  transition: width 0.4s;
}
.player-body { padding: 10px 14px 8px; }

#statusLine {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  gap: 6px;
  min-height: 18px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.dot.narrator { background: var(--narrator-text); animation: pulse 1s infinite; }
.dot.dialogue { background: var(--dialogue-text); animation: pulse 1s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.btn-c {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.btn-c:hover { background: var(--border); }
.btn-c.primary {
  background: var(--accent);
  border-color: var(--accent);
  width: 54px; height: 54px;
  font-size: 1.3rem;
}
.btn-c.primary:hover { background: #9080dd; }
.btn-c:disabled { opacity: 0.3; cursor: default; }

.speed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.spd {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 2px 9px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: sans-serif;
  transition: all 0.15s;
}
.spd.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.toggle-cfg {
  display: flex;
  justify-content: center;
}
.btn-cfg {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 16px;
  padding: 3px 16px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: sans-serif;
}

/* SETTINGS PANEL */
#cfgPanel {
  display: none;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px 14px;
  max-height: 56vh;
  overflow-y: auto;
}
.vcfg-title {
  font-family: sans-serif;
  font-size: 0.88rem;
  font-weight: bold;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-v {
  font-size: 0.7rem;
  padding: 2px 9px;
  border-radius: 10px;
  font-weight: bold;
}
.n-badge { background: var(--narrator-active); color: var(--narrator-text); }
.d-badge { background: var(--dialogue-active); color: var(--dialogue-text); }
.frow {
  margin-bottom: 11px;
  font-family: sans-serif;
}
.frow label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.frow label .val { color: var(--accent); font-weight: bold; }
select.vsel, input[type=range] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: sans-serif;
}
input[type=range] {
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  accent-color: var(--accent);
  background: var(--border);
}
hr.div { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.test-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: sans-serif;
  margin-top: 4px;
}
.detect-info {
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px;
  font-family: sans-serif;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ============================================================
   PANNEAU PERSONNAGES
   ============================================================ */
.char-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  font-family: sans-serif;
}
.char-name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: bold;
  min-width: 70px;
  flex-shrink: 0;
}
.char-gender {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 4px 6px;
  font-size: 0.75rem;
  font-family: sans-serif;
  flex-shrink: 0;
}
.char-voice {
  flex: 1;
  min-width: 100px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 4px 6px;
  font-size: 0.72rem;
  font-family: sans-serif;
}
.toggle-cfg {
  display: flex;
  justify-content: center;
  gap: 8px;
}
