:root {
  color-scheme: dark;
  --bg: #0b0f1a;
  --panel: #131a2a;
  --panel-2: #1a2338;
  --line: #26304a;
  --text: #e8ecf7;
  --muted: #97a3c0;
  --accent: #f43f5e;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 18px 72px;
  background:
    radial-gradient(900px 460px at 50% -160px, rgba(139, 92, 246, 0.24), transparent 70%),
    var(--bg);
  color: var(--text);
  font:
    16px/1.55 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  -webkit-text-size-adjust: 100%;
}

main,
.masthead,
footer {
  max-width: 900px;
  margin: 0 auto;
}

.masthead {
  padding: 44px 0 28px;
  text-align: center;
}

.wordmark {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.wordmark span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 12px auto 0;
  max-width: 540px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ok);
  font-size: 13px;
  font-weight: 600;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}

/*
 * `hidden` doit l'emporter. Toute classe qui fixe un `display` — et `.field` en
 * pose un — bat la feuille de style du navigateur : le champ « Votre fichier
 * audio » restait donc affiché alors qu'aucune musique n'était demandée, et les
 * champs du rédacteur s'affichaient tous les deux à la fois.
 */
[hidden] {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  flex: 1;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input,
textarea,
select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 12px 13px;
  width: 100%;
}

input[type="file"] {
  padding: 9px;
  font-size: 14px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

.hint,
.small {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.small {
  margin-top: 14px;
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.row .field {
  min-width: 150px;
}

button,
.actions .primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border: 0;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 22px;
  width: 100%;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.notice {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
  font-size: 14px;
  white-space: pre-wrap;
}

.status {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.status[data-kind="done"] {
  color: var(--ok);
}

.status[data-kind="error"] {
  color: var(--accent);
}

.track {
  height: 8px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s linear;
}

.stage {
  margin-top: 18px;
  text-align: center;
}

.stage canvas {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 9 / 16;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #000;
}

.stage .hint {
  margin-top: 10px;
}

#results h2,
.explain h2 {
  font-size: 19px;
  margin: 0 0 14px;
}

#results h2 {
  margin: 6px 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.video-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.video-card video {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
  display: block;
}

.video-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.video-body h3 {
  font-size: 15px;
  margin: 0;
  line-height: 1.35;
}

.meta {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}

.desc {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 130px;
  overflow-y: auto;
  margin: 0;
  font-family: inherit;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.actions .primary {
  display: block;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  padding: 12px;
}

.actions button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  padding: 11px;
}

.explain ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.explain li {
  margin-bottom: 10px;
}

.explain li strong {
  color: var(--text);
}

.explain p {
  color: var(--muted);
}

.explain pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  font-size: 13px;
}

a {
  color: var(--accent-2);
}

footer {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding-top: 8px;
}

.status-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
}

.status-row .status {
  flex: 1;
  margin: 0;
}

.elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  flex: none;
}

#report {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

#report summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

#report pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0 8px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* ------------------------------------------------------------------ *
 * Bibliothèque : les vidéos gardées, en liste
 * ------------------------------------------------------------------ */

.library-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.library-head h2 {
  margin: 0;
}

button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  width: auto;
}

button.ghost:hover {
  color: var(--text);
}

.library-search {
  margin: 14px 0 6px;
}

.library-search input {
  width: 100%;
}

/* Un intitulé de période, comme dans une liste de conversations récentes. */
.library-group {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 18px 0 6px;
  text-transform: uppercase;
}

.library-list {
  display: flex;
  flex-direction: column;
}

.library-row {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 15px;
  font-weight: 500;
  gap: 12px;
  padding: 11px 12px;
  text-align: left;
  width: 100%;
}

.library-row:hover,
.library-row[aria-expanded="true"] {
  background: var(--panel-2);
}

/* La vignette tient lieu d'icône : on reconnaît la vidéo avant de lire son titre. */
.library-row .vignette {
  background: #0b0f1a center / cover no-repeat;
  border: 1px solid var(--line);
  border-radius: 7px;
  flex: 0 0 auto;
  height: 44px;
  width: 26px;
}

.library-row .label {
  flex: 1 1 auto;
  min-width: 0;
}

.library-row .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-row .meta {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 400;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-row .chevron {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 18px;
  transition: transform 0.18s;
}

.library-row[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.library-detail {
  border-left: 2px solid var(--line);
  margin: 2px 0 10px 24px;
  padding: 10px 0 4px 16px;
}

.library-detail video {
  background: #000;
  border-radius: 12px;
  display: block;
  max-height: 60vh;
  width: 100%;
}

.library-detail .desc {
  margin-top: 12px;
}

.library-detail .actions {
  margin-top: 12px;
}

/* Reprise d'une génération interrompue : un état, pas une erreur. */
.resume {
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  color: var(--text);
  /* En colonne : sans cela le bouton se glissait au milieu de la phrase, le
     texte reprenant après lui sur la même ligne. */
  display: flex;
  flex-direction: column;
  font-size: 15px;
  gap: 12px;
  line-height: 1.5;
  margin-bottom: 18px;
  padding: 14px 16px;
}

.resume button {
  font-size: 15px;
  padding: 11px 18px;
  width: auto;
}
