/* ============================================================
   MAMOUSSO V30 — fenêtre « Transcrire des fichiers »
   Parcours simplifié : un bouton en haut de page, une fenêtre centrale,
   trois modes, options repliées, un grand bouton bleu « TRANSCRIRE ».
   Couleurs MAMOUSSO (crème, terracotta) ; le bleu est réservé aux
   deux actions de transcription.
   ============================================================ */

:root {
  --up-blue: #2563eb;
  --up-blue-2: #1d4ed8;
  --up-blue-soft: rgba(37, 99, 235, .1);
  --up-blue-shadow: rgba(37, 99, 235, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --up-blue: #3b82f6;
    --up-blue-2: #2563eb;
    --up-blue-soft: rgba(59, 130, 246, .16);
    --up-blue-shadow: rgba(37, 99, 235, .5);
  }
}
:root[data-theme="dark"] {
  --up-blue: #3b82f6;
  --up-blue-2: #2563eb;
  --up-blue-soft: rgba(59, 130, 246, .16);
  --up-blue-shadow: rgba(37, 99, 235, .5);
}

/* ---------------------------------------------------------------- haut de page */
.mxTranscribe .upHero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 24px;
  padding: 26px 30px;
}
.upHeroText { flex: 1 1 320px; min-width: 0; }
.mxTranscribe .upHeroText h1 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 28px); letter-spacing: -.02em; }
.mxTranscribe .upHeroText .hint { margin: 0; max-width: 560px; font-size: 14.5px; }
.upHeroActions { display: flex; flex-wrap: wrap; gap: 10px; }

.mxTranscribe .upMainBtn,
.mxTranscribe .upRecBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease, background-color .2s ease;
}
.mxTranscribe .upMainBtn {
  border: 0;
  background: linear-gradient(180deg, var(--up-blue), var(--up-blue-2));
  color: #fff;
  box-shadow: 0 12px 26px -12px var(--up-blue-shadow), 0 1px 0 rgba(255, 255, 255, .25) inset;
}
.mxTranscribe .upRecBtn {
  border: 1px solid var(--ui-line-strong, #d6d3c7);
  background: var(--ui-surface, #fffdf8);
  color: var(--ui-text, #141413);
}
.upMainBtn svg, .upRecBtn svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.mxTranscribe .upMainBtn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.mxTranscribe .upRecBtn:hover { border-color: var(--ui-accent, #c96442); color: var(--ui-accent, #c96442); }
.mxTranscribe .upMainBtn:focus-visible,
.mxTranscribe .upRecBtn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--up-blue-soft); }
.mxTranscribe .upRecBtn.isLive { border-color: var(--mx-rec, #ef4444); color: var(--mx-rec, #ef4444); }
.mxTranscribe .upRecBtn.isLive svg { animation: upPulse 1.2s ease-in-out infinite; }
@keyframes upPulse { 50% { opacity: .35; } }

.upQuota {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 13px;
  color: var(--ui-muted, #73726c);
}
.upQuota[hidden] { display: none; }
.upQuotaText b { color: var(--ui-text, #141413); font-weight: 700; }
.upQuota[data-low="true"] .upQuotaText b { color: var(--ui-warn, #9a5b06); }
.upQuotaAlt { color: var(--ui-muted, #6b6a63); font-size: 12.5px; }
.mxTranscribe .upQuotaLink { color: var(--ui-accent, #c96442); font-weight: 600; text-decoration: none; }
.mxTranscribe .upQuotaLink:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- fenêtre */
.upDialog {
  width: min(720px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--ui-surface, #fffdf8);
  color: var(--ui-text, #141413);
  box-shadow: 0 30px 80px -20px rgba(20, 20, 19, .45);
  overflow: hidden;
}
.upDialog[open] { display: flex; flex-direction: column; animation: upIn .2s ease both; }
.upDialog::backdrop { background: rgba(20, 20, 19, .45); backdrop-filter: blur(3px); }
@keyframes upIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
body.upDialogOpen { overflow: hidden; }

.mxTabs[hidden] { display: none !important; }
.mxTranscribe.appBody .upBox,
.mxTranscribe .upBox {
  padding: 0 26px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: none;
}
.mxTranscribe .upHead {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin: 0 -26px 16px;
  padding: 18px 20px 14px 26px;
  background: var(--ui-surface, #fffdf8);
  border-bottom: 1px solid var(--ui-line, #e8e6dc);
}
.mxTranscribe .upHead h2 { flex: 1; margin: 0; font-size: 20px; letter-spacing: -.01em; }
.upClose {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ui-muted, #73726c);
  cursor: pointer;
}
.upClose:hover { background: var(--ui-surface-3, #f0eee6); color: var(--ui-text, #141413); }
.upClose svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* zone d'import */
.mxTranscribe .upDrop { min-height: 170px; gap: 4px; text-align: center; padding: 18px; }
.mxTranscribe .upDrop.hasFile { min-height: 0; flex-direction: row; gap: 12px; padding: 12px 16px; }
.mxTranscribe .upDrop.hasFile .mxDropIcon { width: 38px; height: 38px; margin: 0; border-radius: 12px; }
.mxTranscribe .upDrop.hasFile .mxDropIcon svg { width: 20px; height: 20px; }
.mxTranscribe .upDrop.hasFile > span:not(.mxDropIcon) { display: none; }
.mxTranscribe .upDrop strong { font-size: 15.5px; }
.mxTranscribe .upDrop > span:not(.mxDropIcon) { font-size: 12.5px; }
.mxTranscribe .upDropMulti { font-weight: 600; }

.upChip {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 10px 12px 12px;
  border: 1px solid var(--ui-line, #e8e6dc);
  border-radius: 14px;
  background: var(--ui-surface-2, #faf9f5);
  overflow: hidden;
}
.upChip[hidden] { display: none; }
.upChipIcon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--ui-accent-soft, #f9ece4);
  color: var(--ui-accent, #c96442);
}
.upChipIcon svg { width: 20px; height: 20px; fill: currentColor; }
.upChipText { display: grid; min-width: 0; }
.upChipText b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upChipText small { font-size: 12.5px; color: var(--ui-muted, #73726c); }
.upChipState { font-size: 13px; font-weight: 650; white-space: nowrap; color: var(--ui-muted, #73726c); }
.upChip[data-state="ready"] .upChipState { color: var(--ui-ok, #157f3c); }
.upChip[data-state="error"] .upChipState { color: var(--ui-danger, #b42318); white-space: normal; max-width: 220px; text-align: right; }
.upChipRemove {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ui-muted, #73726c);
  cursor: pointer;
}
.upChipRemove:hover { background: var(--ui-surface-3, #f0eee6); color: var(--ui-danger, #b42318); }
.upChipRemove svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.upChipBar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--p, 0%);
  background: var(--up-blue);
  transition: width .35s ease;
}
.upChip[data-state="ready"] .upChipBar { background: var(--ui-ok, #157f3c); }
.upChip[data-state="error"] .upChipBar { background: var(--ui-danger, #b42318); }

.mxTranscribe .upBox .mxUrlOr { margin: 14px 0 10px; }

/* langue */
.mxTranscribe .upField { display: grid; gap: 6px; margin: 18px 0 0; }
.mxTranscribe .upField > span { font-weight: 650; font-size: 14px; color: var(--ui-text, #141413); }

/* modes */
.upModes { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.mxTranscribe .upModes legend { padding: 0; margin-bottom: 8px; font-weight: 650; font-size: 14px; color: var(--ui-text, #141413); }
.upModeRow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.upMode { position: relative; display: block; cursor: pointer; }
.upMode input { position: absolute; opacity: 0; pointer-events: none; }
.upModeBody {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 14px 14px 13px;
  border: 1.5px solid var(--ui-line, #e8e6dc);
  border-radius: 16px;
  background: var(--ui-surface-2, #faf9f5);
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.upModeIcon { font-size: 24px; line-height: 1; }
.mxTranscribe .upModeBody b { font-size: 14.5px; color: var(--ui-text, #141413); }
.mxTranscribe .upModeBody small { font-size: 12.5px; line-height: 1.4; color: var(--ui-muted, #73726c); }
.upMode:hover .upModeBody { border-color: var(--ui-line-strong, #d6d3c7); }
.upMode input:checked + .upModeBody {
  border-color: var(--ui-accent, #c96442);
  background: var(--ui-accent-soft, #f9ece4);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-accent, #c96442) 16%, transparent);
}
.upMode input:focus-visible + .upModeBody { box-shadow: var(--ui-ring, 0 0 0 4px rgba(201, 100, 66, .16)); }
.upModes.isOverridden .upModeBody { opacity: .55; }
.mxTranscribe .upModeOther { margin: 8px 2px 0; font-size: 12.5px; color: var(--ui-muted, #73726c); }
.upModeOther[hidden] { display: none; }

/* paramètres repliés */
.upAdvanced {
  margin: 18px 0 0;
  border: 1px solid var(--ui-line, #e8e6dc);
  border-radius: 16px;
  background: var(--ui-surface, #fffdf8);
}
.upAdvanced > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 14px 44px 14px 16px;
  position: relative;
  list-style: none;
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
}
.upAdvanced > summary::-webkit-details-marker { display: none; }
.upAdvanced > summary::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  transition: transform .2s ease;
  opacity: .6;
}
.upAdvanced[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
.upAdvanced > summary:focus-visible { outline: none; box-shadow: var(--ui-ring, 0 0 0 4px rgba(201, 100, 66, .16)); border-radius: 16px; }
.upAdvSummary { font-weight: 500; font-size: 12.5px; color: var(--ui-accent, #c96442); }
.upAdvSummary[hidden] { display: none; }
.upAdvBody { padding: 0 14px 6px; }
.mxTranscribe .upAdvBody .mxEnhance { margin: 0 0 10px; }
.upOpt { margin-bottom: 10px; border: 1px solid var(--ui-line, #e8e6dc); border-radius: 14px; background: var(--ui-surface-2, #faf9f5); }
.mxTranscribe .upOpt .mxEnhance { margin: 0; border: 0; background: transparent; }
.mxTranscribe .upCount { display: grid; gap: 6px; padding: 0 14px 12px 44px; }
.mxTranscribe .upCount > span { font-size: 13px; font-weight: 600; }
.mxTranscribe .upCount select { max-width: 260px; }
.mxTranscribe .upCount select:disabled { opacity: .5; }
.mxTranscribe .upCount small { font-size: 12px; line-height: 1.4; color: var(--ui-muted, #73726c); }
.upEngine { margin: 4px 0 10px; }
.mxTranscribe .upEngine .upField { margin-top: 0; }
.mxTranscribe .upEngine .upField > span { font-size: 13px; }
.mxTranscribe .upEngine .mxModeCard { margin: 8px 0 0; }

/* bouton TRANSCRIRE */
.upGoRow { position: sticky; bottom: -22px; margin: 18px -26px -22px; padding: 14px 26px 18px; background: var(--ui-surface, #fffdf8); border-top: 1px solid var(--ui-line, #e8e6dc); }
.mxTranscribe.appBody .upGo.mxPrimary,
.mxTranscribe .upGo.mxPrimary {
  margin-top: 0;
  min-height: 58px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--up-blue), var(--up-blue-2));
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 14px 30px -14px var(--up-blue-shadow), 0 1px 0 rgba(255, 255, 255, .25) inset;
}
.mxTranscribe .upGo:hover:not(:disabled) { box-shadow: 0 18px 36px -14px var(--up-blue-shadow); }
.mxTranscribe .upGo:focus-visible { box-shadow: 0 0 0 4px var(--up-blue-soft), 0 14px 30px -14px var(--up-blue-shadow); }
/* l'animation d'apparition de .mxPrimary garde opacity: 1 : on la coupe pour que « grisé » se voie */
.mxTranscribe.appBody .upGo.mxPrimary:disabled,
.mxTranscribe .upGo.mxPrimary:disabled { animation: none; opacity: .4; box-shadow: none; cursor: not-allowed; }
.mxTranscribe .upGoHint { margin: 8px 0 0; text-align: center; font-size: 13px; color: var(--ui-muted, #73726c); }
.upGoHint[hidden] { display: none; }
.mxTranscribe .upGoRow .mxFootnote { margin-top: 6px; font-size: 12px; }

/* l'enregistreur dans la fenêtre */
.mxTranscribe .upBox .mxRecorder { padding-top: 6px; }

/* ---------------------------------------------------------------- téléphone */
@media (max-width: 640px) {
  .mxTranscribe .upHero { padding: 20px 16px; }
  .upHeroActions { width: 100%; }
  .mxTranscribe .upMainBtn { flex: 1 1 100%; }
  .mxTranscribe .upRecBtn { flex: 1 1 100%; min-height: 48px; }
  .upDialog { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .mxTranscribe.appBody .upBox, .mxTranscribe .upBox { padding: 0 16px 16px; }
  .mxTranscribe .upHead { margin: 0 -16px 14px; padding: 12px 10px 10px 16px; }
  .mxTranscribe .upHead h2 { font-size: 18px; }
  .upHead .mxStatus { display: none; }
  .upModeRow { gap: 6px; }
  .upModeBody { padding: 10px 8px; align-items: center; text-align: center; }
  .mxTranscribe .upModeBody b { font-size: 13px; }
  .mxTranscribe .upModeBody small { font-size: 11px; }
  .mxTranscribe .upCount { padding-left: 14px; }
  .upChip { grid-template-columns: 34px minmax(0, 1fr) 34px; }
  .upChipIcon { width: 34px; height: 34px; }
  .upChipState { grid-column: 2; grid-row: 2; }
  .upChipRemove { grid-column: 3; grid-row: 1 / span 2; }
  .upGoRow { bottom: -16px; margin: 16px -16px -16px; padding: 12px 16px 16px; }
}

/* ---------------------------------------------------------------- V31 vidéo originale en arrière-plan
   « Son d'abord » : la transcription part avec le son, la vidéo complète suit. Petit panneau
   en bas à droite, au-dessus de l'éditeur et de son lecteur. */
.afPanel {
  position: fixed;
  right: 16px;
  bottom: 92px;
  z-index: 1100;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  font: 13px/1.4 Inter, system-ui, sans-serif;
}
.afPanel[hidden] { display: none; }
.afRow {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
  overflow: hidden;
  border: 1px solid var(--ui-line, #e8e6dc);
  border-radius: 12px;
  background: var(--ui-surface, #fffdf8);
  color: var(--ui-text, #141413);
  box-shadow: 0 10px 28px rgba(20, 20, 19, .14);
}
.afText { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.afRow[data-state="received"] .afText { color: var(--ui-ok, #157f3c); font-weight: 600; }
.afRow[data-state="failed"] .afText,
.afRow[data-state="refused"] .afText { color: var(--ui-danger, #b42318); }
.afActions { display: flex; gap: 6px; flex: 0 0 auto; }
.afActions button {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--ui-line-strong, #d6d3c7);
  border-radius: 8px;
  background: var(--ui-surface-2, #faf9f5);
  color: var(--ui-text, #141413);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.afActions button:hover { border-color: var(--ui-accent, #c96442); color: var(--ui-accent, #c96442); }
.afBar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--p, 0%);
  background: var(--up-blue);
  transition: width .35s ease;
}
@media (max-width: 640px) {
  .afPanel { right: 16px; left: 16px; width: auto; bottom: 84px; }
}
