/* ════════════════════════════════════════════════════════════════════════
   LISEUSE v2 — tts-notes.css : compléments « lecture vocale + bloc-notes »
   ─────────────────────────────────────────────────────────────────────────
   Module : tts.js (dock [data-tts-dock]) + notes.js (panneau [data-panel-notes]).
   Contrat : n'utilise QUE les tokens :root de v2.css (var(--acc), --glass-*,
   --stroke, --r-*, --shadow-*, --display, --ui, --serif, --paper…). Le socle
   .tts-dock / .panel / .panel__tabs / .panel__tab est déjà stylé par v2.css ;
   ici on ne fait qu'AJOUTER (contenu interne du dock et du panneau).
   ════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════ DOCK TTS (interne) ═══════════════════════════ */
.tts-dock__head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.tts-dock__head b {
  font-family: var(--display); font-size: 16px; font-weight: 600; flex: 1;
  display: flex; align-items: center; gap: 8px;
}
.tts-dock__head b svg { width: 18px; height: 18px; color: var(--acc-3); }
.tts-dock__close { width: 34px; height: 34px; }

/* — waveform animée (barres CSS) — */
.tts-wave {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  height: 26px; margin-bottom: 14px; opacity: .35; transition: opacity .3s var(--ease);
}
.tts-wave.is-playing { opacity: 1; }
.tts-wave span {
  display: block; width: 3px; height: 100%; border-radius: 3px;
  background: var(--grad-acc); transform: scaleY(.25); transform-origin: center;
}
.tts-wave.is-playing span { animation: ttsWave 1s var(--ease) infinite; }
.tts-wave span:nth-child(1) { animation-delay: -.9s; }
.tts-wave span:nth-child(2) { animation-delay: -.75s; }
.tts-wave span:nth-child(3) { animation-delay: -.6s; }
.tts-wave span:nth-child(4) { animation-delay: -.45s; }
.tts-wave span:nth-child(5) { animation-delay: -.3s; }
.tts-wave span:nth-child(6) { animation-delay: -.15s; }
.tts-wave span:nth-child(7) { animation-delay: -.55s; }
@keyframes ttsWave {
  0%, 100% { transform: scaleY(.25); }
  50%      { transform: scaleY(1); }
}

/* — contrôles transport — */
.tts-transport {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px;
}
.tts-transport .iconbtn { width: 44px; height: 44px; border-radius: 50%; }
.tts-transport .tts-play {
  width: 54px; height: 54px; color: #fff;
  background: var(--grad-acc); border-color: transparent; box-shadow: var(--shadow-acc);
}
.tts-transport .tts-play:hover { filter: brightness(1.08); border-color: transparent; }
.tts-transport .tts-play svg { width: 22px; height: 22px; }

.tts-status {
  text-align: center; font-size: 12.5px; color: var(--text-3);
  margin-bottom: 12px; min-height: 16px;
}
.tts-status.is-error { color: var(--err); }

/* — réglages (voix, vitesse, émotions) — */
.tts-field { margin-bottom: 12px; }
.tts-field > label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 6px;
}
.tts-field select {
  width: 100%; min-height: 42px; padding-right: 34px;
}
.tts-field select optgroup { color: var(--text); background: #1a1626; font-weight: 700; }
.tts-field select option { color: var(--text); background: #14111e; font-weight: 400; }

.tts-speed { display: flex; align-items: center; gap: 10px; }
.tts-speed input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px;
  border-radius: 4px; background: rgba(255, 255, 255, .12); outline: none;
}
.tts-speed input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--acc); box-shadow: var(--shadow-1); cursor: pointer;
}
.tts-speed input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: var(--acc); box-shadow: var(--shadow-1); cursor: pointer;
}
.tts-speed__val {
  min-width: 42px; text-align: right; font-size: 13px; font-weight: 600;
  color: var(--text-2); font-variant-numeric: tabular-nums;
}

.tts-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13.5px; color: var(--text-2); user-select: none;
}
.tts-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.tts-toggle__track {
  position: relative; flex-shrink: 0; width: 40px; height: 24px; border-radius: 999px;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--stroke);
  transition: all .2s var(--ease);
}
.tts-toggle__track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--text-3); transition: all .2s var(--spring);
}
.tts-toggle input:checked + .tts-toggle__track {
  background: var(--acc-soft); border-color: rgba(139, 92, 246, .5);
}
.tts-toggle input:checked + .tts-toggle__track::after {
  transform: translateX(16px); background: var(--acc);
}
.tts-toggle input:focus-visible + .tts-toggle__track { outline: 2px solid var(--acc); outline-offset: 2px; }

.tts-dock__page {
  width: 100%; margin-top: 4px; justify-content: center;
}

/* ═══════════════════════════ BLOC-NOTES (interne) ═══════════════════════ */
.panel__head-actions { display: flex; gap: 6px; align-items: center; }
.panel__head-actions .iconbtn { width: 36px; height: 36px; }

/* onglets (le socle .panel__tabs / .panel__tab est dans v2.css) */
[data-panel-notes] .panel__body { padding-top: 12px; }

/* — carte d'extrait — */
.note-card {
  padding: 14px 15px; margin-bottom: 12px; border-radius: var(--r-m);
  background: var(--glass-2); border: 1px solid var(--stroke);
  transition: border-color .2s var(--ease);
}
.note-card:hover { border-color: var(--stroke-lit); }
.note-card--free { border-left: 3px solid var(--acc-2); }
.note-card__text {
  font-family: var(--serif); font-size: 15px; line-height: 1.6; color: var(--text);
  margin: 0 0 10px; white-space: pre-wrap; word-break: break-word;
}
.note-card--extract .note-card__text {
  padding-left: 12px; border-left: 3px solid var(--acc);
  font-style: italic; color: var(--text);
}
.note-card__meta {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
  font-size: 12px; color: var(--text-3);
}
.note-card__src { color: var(--text-2); font-weight: 600; }
.note-card__src svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; opacity: .7; }
.note-card__dot { opacity: .5; }
.note-card__actions {
  display: flex; gap: 4px; margin-left: auto;
}
.note-card__actions .iconbtn {
  width: 34px; height: 34px; border-radius: 9px;
}
.note-card__actions .iconbtn svg { width: 16px; height: 16px; }

/* édition inline d'un extrait */
.note-card__edit {
  width: 100%; min-height: 88px; padding: 11px 13px; margin-bottom: 8px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--acc); border-radius: var(--r-s);
  color: var(--text); font-family: var(--serif); font-size: 15px; line-height: 1.6;
  resize: vertical; outline: none;
}
.note-card__edit-row { display: flex; gap: 8px; justify-content: flex-end; }

/* champ « écrire une note » collé en bas du panneau Extraits */
.notes-compose {
  flex-shrink: 0; padding: 12px 16px; border-top: 1px solid var(--stroke);
  background: linear-gradient(0deg, var(--glass-2), transparent);
}
.notes-compose textarea {
  width: 100%; min-height: 46px; max-height: 140px; padding: 11px 13px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--stroke); border-radius: var(--r-s);
  color: var(--text); font-family: var(--ui); font-size: 14px; line-height: 1.5;
  resize: none; outline: none; transition: border-color .2s var(--ease);
}
.notes-compose textarea:focus { border-color: var(--acc); }
.notes-compose__row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.notes-compose__hint { font-size: 11.5px; color: var(--text-3); flex: 1; }

/* — onglet Résumés IA — */
.notes-summary__actions { display: flex; gap: 9px; margin-bottom: 16px; flex-wrap: wrap; }
.notes-summary__actions .btn { flex: 1; min-width: 140px; justify-content: center; }

.notes-summary__body {
  font-family: var(--serif); font-size: 15px; line-height: 1.65; color: var(--text);
}
.notes-summary__body h4 {
  font-family: var(--display); font-size: 16px; font-weight: 600; color: var(--text);
  margin: 18px 0 8px;
}
.notes-summary__body p { margin: 0 0 12px; }
.notes-summary__chapter {
  padding: 12px 14px; margin-bottom: 10px; border-radius: var(--r-s);
  background: var(--glass-1); border: 1px solid var(--stroke);
}
.notes-summary__chapter b {
  display: block; font-family: var(--display); font-size: 14.5px; margin-bottom: 5px; color: var(--acc);
}

/* état d'attente rassurant (résumé IA long) */
.notes-wait {
  display: grid; place-items: center; gap: 14px; padding: 40px 20px; text-align: center;
}
.notes-wait__spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(139, 92, 246, .2); border-top-color: var(--acc);
  animation: spin .9s linear infinite;
}
.notes-wait p { color: var(--text-2); font-size: 14px; margin: 0; max-width: 260px; }
.notes-wait small { color: var(--text-3); font-size: 12.5px; }

/* état vide / dégradé (RAG hors ligne) */
.notes-state {
  text-align: center; color: var(--text-3); padding: 46px 20px; font-size: 14px;
}
.notes-state svg { width: 34px; height: 34px; margin-bottom: 12px; opacity: .5; }
.notes-state--offline { color: var(--warn); }

/* ═══════════════════════════ RESPONSIVE ═══════════════════════════ */
@media (max-width: 640px) {
  .tts-transport .iconbtn { width: 48px; height: 48px; }
  .tts-transport .tts-play { width: 58px; height: 58px; }
  .notes-summary__actions .btn { flex-basis: 100%; }
}
