:root {
  /* Fond bleu nuit, bleu MediaVior pour l'action, une couleur par type de média.
     (Les noms --brass… datent de l'ancien thème doré : --brass = couleur d'accent.) */
  color-scheme: dark;
  --ink: #121821;
  --surface: #1B232E;
  --surface-raised: #212B38;
  --hairline: #3A4453;
  --hairline-soft: #2A3442;
  --brass: #3B8CC2;
  --brass-bright: #58A3D6;
  --brass-dim: #2C6690;
  --on-accent: #FFFFFF;
  --paper: #E9ECF1;
  --paper-dim: #9BA3B0;
  --muted: #5D6676;
  --teal: #57A98F;
  --danger: #E0674F;
  --c-son: #E8B54A;
  --c-video: #E0674F;
  --c-zip: #3B8CC2;
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Thème clair : suit le réglage de l'ordinateur ou du téléphone */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ink: #F3F5F8;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --hairline: #D5DBE3;
    --hairline-soft: #E6EAF0;
    --brass: #2F7CAC;
    --brass-bright: #256A95;
    --brass-dim: #8DB4CF;
    --paper: #17202B;
    --paper-dim: #5E6876;
    --muted: #98A2AF;
    --teal: #2F8F73;
    --danger: #C4533A;
    --c-son: #C98A12;
    --c-video: #C4533A;
    --c-zip: #2F7CAC;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  padding: 72px 24px 96px;
  padding-top: max(72px, env(safe-area-inset-top));
  background:
    radial-gradient(ellipse 60% 40% at 50% -5%, color-mix(in srgb, var(--brass) 12%, transparent), transparent 70%),
    var(--ink);
  background-attachment: fixed;
}

::selection { background: var(--brass); color: var(--on-accent); }

.hidden { display: none !important; }

.page {
  width: 100%;
  max-width: 620px;
}
.page--wide { max-width: 880px; }

/* ---------- Coquille de l'appli ----------
   Ordinateur : page Télécharger au centre, panneau fixe à droite (En cours / Bibliothèque).
   Téléphone : une vue à la fois, onglets en bas. */

body.shell {
  --side-w: 420px;
  --tabbar-h: 64px;
  display: block;
  padding: 0;
}

.main {
  margin-right: var(--side-w);
  padding: max(28px, env(safe-area-inset-top)) 48px 24px;
}
/* Pied de page moins haut : « Plusieurs liens » tient sans barre de défilement (écran 1080p à 125 %) */
.main > .app-foot:not(.app-foot--small) { margin-top: 32px; }
.main > .view, .topbar {
  max-width: 720px;
  margin: 0 auto;
}
.main > .view { animation: rise 0.3s var(--ease) both; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}
.topbar__local {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar__local .btn { margin-top: 0; }

/* Version PC : boutons en bas du panneau de droite */
.side__foot {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline-soft);
}
.side__tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.side-tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border: 1px solid transparent; border-radius: 10px;
  background: none; color: var(--paper-dim); font: inherit; font-size: 0.76rem; cursor: pointer;
}
.side-tool .icon { width: 20px; height: 20px; }
/* Nouvelle version détectée : petit rond « ! » sur « Réglages » */
.side-tool--alert { position: relative; }
.side-tool__badge {
  position: absolute; top: 3px; right: calc(50% - 19px); width: 15px; height: 15px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brass); color: #fff;
  font-size: 0.66rem; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px var(--surface-raised, #fff);
}
.side-tool:hover, .side-tool:focus-visible { color: var(--paper); background: var(--surface); border-color: var(--hairline); }
.side__quit { align-self: center; font-size: 0.78rem; }
.side__foot #updateBtn { margin: 0; width: 100%; }
@media (max-width: 960px) {
  .side__foot { padding: 16px 0 0; margin-top: 24px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  text-decoration: none;
}

.brand__mark {
  width: 36px;
  height: 36px;
  flex: none;
  color: var(--brass);
  padding: 6px;
  border: 1px solid var(--brass-dim);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brass) 6%, transparent);
}

.brand__name {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Panneau de droite */
.side {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  border-left: 1px solid var(--hairline-soft);
}

.side__tabs {
  display: flex;
  gap: 4px;
  padding: max(20px, env(safe-area-inset-top)) 20px 0;
  border-bottom: 1px solid var(--hairline-soft);
}

.pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.pane__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; /* fenêtre étroite : les boutons passent dessous plutôt que d'écraser le compte */
  gap: 6px 12px;
  margin-bottom: 12px;
}
.pane__actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; margin-left: auto; }
.pane__stats {
  margin: 0;
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--paper-dim);
  font-variant-numeric: tabular-nums;
}

.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  color: var(--paper-dim);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}
.side__tabs .tab { margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--paper); }
.tab.is-active { color: var(--brass); }
.side__tabs .tab.is-active { border-bottom-color: var(--brass); }
.tab__icon { display: inline-flex; }
.tab__icon .icon { width: 20px; height: 20px; }

.tab__badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brass);
  color: var(--on-accent);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab__badge--muted { background: var(--hairline); color: var(--paper); }

/* Onglets du bas : téléphone seulement */
.tabbar { display: none; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.view-head__title {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
}

.view-head__sub {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--paper-dim);
  margin: 6px 0 0;
  max-width: 52ch;
  font-variant-numeric: tabular-nums;
}
.view-head__sub:empty { display: none; }

/* Les trois façons de télécharger */
.ways {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.ways__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--paper-dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ways__btn:hover { border-color: var(--hairline); color: var(--paper); }
.ways__btn.is-active {
  border-color: var(--brass-dim);
  background: color-mix(in srgb, var(--brass) 8%, transparent);
  color: var(--paper);
}
.ways__icon { display: inline-flex; flex: none; color: var(--brass-dim); }
.ways__btn.is-active .ways__icon { color: var(--brass); }
.ways__icon .icon { width: 22px; height: 22px; }
.ways__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ways__text strong { font-size: 0.92rem; font-weight: 600; }
.ways__text small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--paper-dim);
}
.ways__count { min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; font-size: 0.66rem; }

.way { animation: rise 0.25s var(--ease) both; }
.way > .panel + .panel { margin-top: 16px; }
#batchInput { width: 100%; resize: vertical; min-height: 84px; }

/* Petite notification (« prêt, voir dans la bibliothèque ») */
.toast {
  position: fixed;
  z-index: 30;
  left: 0;
  right: var(--side-w, 0px);
  bottom: 24px;
  margin: 0 auto;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
  font-size: 0.88rem;
  animation: rise 0.3s var(--ease) both;
}
.toast__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast__action {
  flex: none;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  color: var(--brass);
  cursor: pointer;
}
.toast__action:hover { background: color-mix(in srgb, var(--brass) 12%, transparent); }

/* Écran moyen : panneau un peu plus étroit */
@media (max-width: 1200px) and (min-width: 961px) {
  body.shell { --side-w: 360px; }
  .main { padding-left: 32px; padding-right: 32px; }
}

/* Téléphone et tablette : une vue à la fois, onglets en bas comme une appli */
@media (max-width: 960px) {
  body.shell { --side-w: 0px; }
  .main {
    margin-right: 0;
    padding: max(20px, env(safe-area-inset-top)) 20px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  }
  .topbar { margin-bottom: 24px; }
  .view-head__title { font-size: 1.7rem; }

  /* Panneau de droite : devient une page entière */
  .side {
    position: static;
    width: auto;
    background: none;
    border-left: none;
    padding: 0 20px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  }
  .side__tabs { display: none; }
  .pane { overflow: visible; padding: 0; }
  body[data-view="telecharger"] .side { display: none; }
  body:not([data-view="telecharger"]) .main > .view,
  body:not([data-view="telecharger"]) .main > .app-foot { display: none; }
  body:not([data-view="telecharger"]) .main { padding-bottom: 0; }
  .side::before {
    display: block;
    margin: 0 0 16px;
    font-family: 'Fraunces', serif;
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.015em;
  }
  body[data-view="encours"] .side::before { content: "En cours"; }
  body[data-view="bibliotheque"] .side::before { content: "Dans le coffre"; }

  .tabbar {
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    padding: 0 8px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--ink) 92%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--hairline-soft);
  }
  .tabbar .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    height: var(--tabbar-h);
    padding: 6px 4px;
    font-size: 0.72rem;
  }
  .tabbar .tab.is-active .tab__icon { background: color-mix(in srgb, var(--brass) 14%, transparent); }
  .tabbar .tab__icon { padding: 3px 16px; border-radius: 999px; transition: background 0.15s ease; }
  .tabbar .tab__icon .icon { width: 22px; height: 22px; }
  .tabbar .tab__label { white-space: nowrap; }
  .tabbar .tab__badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 10px);
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    font-size: 0.66rem;
    box-shadow: 0 0 0 2px var(--ink);
  }
  .toast {
    bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .ways { gap: 6px; }
  .ways__btn { flex-direction: column; gap: 4px; padding: 10px 6px; text-align: center; }
  .ways__text { align-items: center; }
  .ways__text strong { font-size: 0.82rem; }
  .ways__text small { font-size: 0; gap: 0; } /* sous-titres masqués, pastille gardée */
}

#batch .mode-toggle { margin-top: 18px; }

/* ---------- Panneaux ---------- */

.panel {
  background: linear-gradient(180deg, var(--surface-raised), var(--surface) 120px);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--paper) 4%, transparent) inset, 0 12px 32px -16px rgba(0, 0, 0, 0.6);
  animation: rise 0.4s var(--ease) both;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel__title {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.panel__aside {
  font-size: 0.8rem;
  color: var(--paper-dim);
  font-variant-numeric: tabular-nums;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.field { display: block; min-width: 0; }

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 8px;
}

.hint {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--paper-dim);
  opacity: 0.75;
  margin: 10px 0 0;
}

.empty {
  font-size: 0.9rem;
  color: var(--paper-dim);
  text-align: center;
  padding: 18px 0 6px;
  margin: 0;
}

/* ---------- Champs ---------- */

.intake-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

input[type="text"], input[type="search"], input[type="password"], textarea, select {
  background: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: none;
  line-height: 1.45;
  min-height: 46px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

::placeholder { color: var(--muted); }

input[type="text"]:hover, input[type="search"]:hover, input[type="password"]:hover, textarea:hover, select:hover { border-color: #4A5566; }

input[type="text"]:focus, input[type="search"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 18%, transparent);
}

select:disabled, input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Liste des formats avec le signet « préféré » (formats.js) : couleurs de l'appli */
.mvf {
  --mvf-bg: var(--ink);
  --mvf-raised: var(--surface-raised);
  --mvf-line: var(--hairline);
  --mvf-text: var(--paper);
  --mvf-dim: var(--paper-dim);
  --mvf-accent: var(--brass);
  --mvf-accent-text: var(--brass-bright);
  --mvf-hover: color-mix(in srgb, var(--brass) 14%, transparent);
  --mvf-pad: 12px 14px;
  --mvf-size: 0.95rem;
}

button:focus-visible, a:focus-visible, [role="slider"]:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%239BA3B0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ---------- Boutons ---------- */

.btn {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
/* Un bouton caché (attribut hidden) doit vraiment disparaître : sinon display:inline-flex
   le laisse visible, vide (ex. « Mettre à jour » des Réglages quand il n'y a pas de mise à jour). */
.btn[hidden] { display: none; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn--ghost {
  background: color-mix(in srgb, var(--brass) 6%, transparent);
  border-color: var(--brass-dim);
  color: var(--brass);
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--brass);
  background: color-mix(in srgb, var(--brass) 12%, transparent);
}

.btn--sm { padding: 8px 12px; font-size: 0.84rem; }

.btn--solid {
  background: var(--brass);
  color: var(--on-accent);
  width: 100%;
  margin-top: 24px;
  font-weight: 600;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--brass) 60%, transparent);
}
.btn--solid:hover:not(:disabled) { background: var(--brass-bright); }

.btn--success {
  background: var(--teal);
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--teal) 70%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  text-align: center;
  animation: rise 0.35s var(--ease) both;
}
.btn--success:hover:not(:disabled) { background: #57AD9B; }

.btn-link {
  background: none;
  border: none;
  padding: 4px 2px;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--paper-dim);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
  white-space: nowrap;
}
.btn-link:hover:not(:disabled) { color: var(--paper); text-decoration-color: currentColor; }
.btn-link:disabled { opacity: 0.5; cursor: default; }

.icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--paper-dim);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-raised); color: var(--brass); border-color: var(--hairline-soft); }
.icon-btn--danger:hover { color: var(--danger); }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm .icon { width: 14px; height: 14px; }
.icon-btn--lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brass);
  color: var(--on-accent);
}
.icon-btn--lg:hover { background: var(--brass-bright); color: var(--on-accent); }

/* Spinner dans les boutons pendant un chargement */
.btn.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Messages ---------- */

.error {
  color: var(--danger);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 14px 0 0;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  word-break: break-word;
  white-space: pre-line;
}

/* ---------- Résumé du média ---------- */

.media-summary {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline-soft);
}

.media-summary__thumb {
  width: 136px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
  background: var(--ink);
}

.media-summary__text { min-width: 0; }

.media-summary__text h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2px 0 10px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-summary__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
  border-radius: 999px;
  padding: 2px 10px;
}
.tag:empty { display: none; }

.tag--muted {
  color: var(--paper-dim);
  background: transparent;
  border-color: var(--hairline);
  font-variant-numeric: tabular-nums;
}

.tag--small { font-size: 0.68rem; padding: 0 7px; margin-right: 6px; vertical-align: 1px; }

/* ---------- Bascule Vidéo / Audio ---------- */

.mode-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ink);
  border: 1px solid var(--hairline-soft);
  border-radius: 10px;
  width: fit-content;
  margin-bottom: 24px;
}

.mode-toggle__btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--paper-dim);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-toggle__btn:hover { color: var(--paper); }

.mode-toggle__btn.is-active {
  background: var(--surface-raised);
  color: var(--brass);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.options-grid--3 { grid-template-columns: 1fr 1fr 1fr; }

/* Explication courte du format choisi */
.option-hint {
  margin: 10px 0 0;
  max-width: 62ch;
}

/* ---------- Plusieurs liens ---------- */

.batch-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  background: var(--ink);
}

.batch-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  font-size: 0.86rem;
}
.batch-list__item + .batch-list__item { border-top: 1px solid var(--hairline-soft); }

.batch-list__url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--paper-dim);
}

/* ---------- Liste de sons ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sons-drop {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sons-drop .hint { margin: 0; }
.sons-drop.is-over { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 6%, transparent); }
.sons-drop label.btn { cursor: pointer; }

#sonsInfo { margin-top: 12px; white-space: pre-line; }

.sons-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  background: var(--ink);
}
.sons-list:empty { display: none; }

.sons-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
}
.sons-list__item + .sons-list__item { border-top: 1px solid var(--hairline-soft); }
.sons-list__body { flex: 1; min-width: 0; }

input[type="text"].sons-list__input {
  border-color: transparent;
  background: transparent;
  padding: 7px 8px;
  font-size: 0.88rem;
}
input[type="text"].sons-list__input:hover { border-color: var(--hairline); }

.sons-list__note {
  padding: 0 8px 6px;
  font-size: 0.76rem;
  color: var(--danger);
}

.sons-list__pick {
  padding: 0 8px 6px;
  font-size: 0.76rem;
  color: var(--teal);
  overflow-wrap: anywhere;
}
.sons-list__note .btn-link, .sons-list__pick .btn-link { font-size: inherit; padding: 0; }

/* ---------- Fenêtre YouTube ---------- */

.yt-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--paper);
  overflow-y: auto;
}
.yt-dialog::backdrop { background: color-mix(in srgb, var(--ink) 72%, transparent); }
.yt-dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.yt-dialog__heading { min-width: 0; }
.yt-dialog__heading .hint { margin: 4px 0 0; overflow-wrap: anywhere; }
.yt-dialog__search { display: flex; gap: 8px; margin-top: 14px; }
.yt-dialog__search input { flex: 1; min-width: 0; }
.yt-dialog__search .btn { margin-top: 0; flex: none; }
.yt-dialog__player { margin-top: 14px; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.yt-dialog__player iframe { width: 100%; height: 100%; border: 0; display: block; }
#ytInfo { margin: 12px 0 0; }
.yt-dialog__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.yt-dialog__foot .hint { margin: 0; }

.yt-results { list-style: none; margin: 14px 0 0; padding: 0; }
.yt-results:empty { display: none; }
.yt-results__item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); }
.yt-results__item + .yt-results__item { border-top: 1px solid var(--hairline-soft); }
.yt-results__item.is-playing { background: var(--surface-raised); }
.yt-results__preview {
  position: relative;
  flex: none;
  width: 112px;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--ink);
  cursor: pointer;
}
.yt-results__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-results__preview .icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
.yt-results__body { flex: 1; min-width: 0; }
.yt-results__title { font-size: 0.88rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-results__meta { margin-top: 3px; font-size: 0.76rem; color: var(--paper-dim); }
.yt-results__item .btn { margin-top: 0; flex: none; width: auto; }
.yt-dialog__search .btn { width: auto; }

/* « Chercher une meilleure source » sous le choix du son */
/* Bouton à droite de Vidéo / Audio ; le résultat de la recherche s'affiche sous l'aide */
.mode-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.mode-row .mode-toggle { margin-bottom: 0; }
.mode-row .better__btn { width: auto; margin-top: 0; }
.better .js-better-info { margin-top: 12px; }
.better__list { margin-top: 8px; }
.better__badge { display: inline-block; padding: 1px 7px; margin-right: 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; background: var(--surface-raised); }
.better__badge--lossless { background: var(--brass); color: #fff; }

@media (max-width: 520px) {
  .yt-dialog { padding: 16px; }
  .yt-results__preview { width: 84px; }
}

.sons-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 18px;
}
.sons-actions .field { flex: 0 0 240px; }
.sons-actions .btn { flex: 1.4; margin-top: 0; }

#sonsHint { margin-top: 10px; }

.sons-zip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 16px 0 0;
}
.sons-zip .hint { margin: 0; }
.sons-progress { margin: 14px 0 0; }
.sons-progress .progress--slim { margin: 0 0 6px; }
.sons-progress .hint { margin: 0; }
.sons-zip .btn { display: inline-flex; align-items: center; gap: 8px; color: var(--on-accent); text-decoration: none; }

@media (max-width: 560px) {
  .sons-actions { flex-direction: column; align-items: stretch; }
  .sons-actions .field { flex: none; }
}

/* ---------- Progression ---------- */

.progress {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress__track {
  flex: 1;
  height: 8px;
  background: var(--ink);
  border: 1px solid var(--hairline-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brass-dim), var(--brass));
  border-radius: 999px;
  transition: width 0.4s var(--ease);
}

/* Attente ou conversion : pas de pourcentage, on montre que ça travaille */
.progress.is-busy .progress__fill {
  background: linear-gradient(90deg, var(--brass-dim) 0%, var(--brass-bright) 50%, var(--brass-dim) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

.progress.is-done .progress__fill { background: var(--teal); }

.progress__text {
  font-size: 0.8rem;
  color: var(--paper-dim);
  min-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.progress--slim { margin: 8px 0 6px; }
.progress--slim .progress__track { height: 5px; }

/* ---------- File d'attente ---------- */

.job-list, .item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.job {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  animation: rise 0.3s var(--ease) both;
}
.job + .job { border-top: 1px solid var(--hairline-soft); }
.job.is-muted { opacity: 0.55; }

.job__thumb, .item__thumb {
  width: 64px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  border: 1px solid var(--hairline-soft);
  color: var(--brass-dim);
}
.job__thumb img, .item__thumb img { width: 100%; height: 100%; object-fit: cover; }

.job__body { flex: 1; min-width: 0; }
.job__actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

.job__title, .item__title {
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job__meta, .item__meta {
  font-size: 0.78rem;
  color: var(--paper-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job__meta.is-error { color: var(--danger); white-space: normal; }

/* ---------- Bibliothèque ---------- */

.library-filter {
  position: sticky;
  top: 12px;
  z-index: 5;
  margin-bottom: 14px;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.8);
}

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.item:hover { background: color-mix(in srgb, var(--paper) 3%, transparent); }
.item + .item { box-shadow: 0 -1px 0 var(--hairline-soft); }
.item.is-new { animation: highlight 2.4s var(--ease) both; }
@keyframes highlight {
  0%, 40% { background: color-mix(in srgb, var(--teal) 16%, transparent); }
  100% { background: transparent; }
}

.item__thumb { width: 72px; }
.item__body { flex: 1; min-width: 0; }
.item__title { margin-bottom: 3px; }

.item__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Sélection multiple */
.item--selectable { cursor: pointer; user-select: none; -webkit-user-select: none; }
.item--selectable:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }
.item--selectable.is-selected { background: color-mix(in srgb, var(--brass) 10%, transparent); }

.item__check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline);
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.item__check .icon { width: 14px; height: 14px; }
.item--selectable:hover .item__check { border-color: var(--brass-dim); }
.is-selected .item__check { background: var(--brass); border-color: var(--brass); color: var(--on-accent); }

.selbar {
  position: sticky;
  z-index: 10;
  bottom: 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
  animation: rise 0.25s var(--ease) both;
}
.selbar__count {
  flex: 1;
  min-width: 0;
  font-size: 0.86rem;
  color: var(--paper-dim);
  font-variant-numeric: tabular-nums;
}
.selbar .btn .icon { width: 16px; height: 16px; }

.btn--danger {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  color: var(--danger);
}
.btn--danger:hover:not(:disabled) { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }

/* Téléphone : la barre passe au-dessus des onglets, boutons sur une deuxième ligne */
@media (max-width: 960px) {
  .selbar {
    bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .selbar__count { grid-row: 1; grid-column: 2; text-align: right; }
  .selbar #selAll { grid-row: 1; grid-column: 1; justify-self: start; }
  .selbar #selDownload { grid-row: 2; grid-column: 1; }
  .selbar #selDelete { grid-row: 2; grid-column: 2; }
}

/* ---------- Éditeur ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--paper-dim);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--brass); }

.editor-head { margin-bottom: 24px; animation: rise 0.4s var(--ease) both; }
.editor-head h1 {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.stage {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  margin-bottom: 18px;
}
.stage video {
  display: block;
  width: 100%;
  max-height: 56vh;
  background: #000;
  cursor: pointer;
}
.stage__fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.timeline {
  position: relative;
  height: 96px;
  background: var(--ink);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.timeline.is-loading::after {
  content: "Analyse de la piste audio…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--paper-dim);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brass) 7%, transparent), transparent) 0 0 / 50% 100% no-repeat;
  animation: sweep 1.4s linear infinite;
}
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.timeline__wave {
  position: absolute;
  inset: 8px 0;
  width: 100%;
  height: calc(100% - 16px);
  object-fit: fill;
  opacity: 0.85;
  pointer-events: none;
}

.timeline__shade {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  pointer-events: none;
}
.timeline__shade--left { left: 0; }
.timeline__shade--right { right: 0; }

.timeline__sel {
  position: absolute;
  top: 0;
  bottom: 0;
  border-top: 2px solid var(--brass);
  border-bottom: 2px solid var(--brass);
  pointer-events: none;
}

/* Rampes de fondu dessinées sur la sélection */
.timeline__fade {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}
/* Triangle atténué au-dessus de la rampe, et la rampe elle-même en trait doré */
.timeline__fade--in {
  left: 0;
  background: linear-gradient(to bottom right,
    color-mix(in srgb, var(--ink) 75%, transparent) calc(50% - 1px), var(--brass) calc(50% - 1px),
    var(--brass) calc(50% + 1px), transparent calc(50% + 1px));
}
.timeline__fade--out {
  right: 0;
  background: linear-gradient(to bottom left,
    color-mix(in srgb, var(--ink) 75%, transparent) calc(50% - 1px), var(--brass) calc(50% - 1px),
    var(--brass) calc(50% + 1px), transparent calc(50% + 1px));
}

.timeline__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  margin-left: -10px;
  cursor: ew-resize;
  z-index: 2;
}
.timeline__handle::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brass);
  border-radius: 2px;
}
.timeline__handle::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 12px;
  height: 28px;
  margin-top: -14px;
  background: var(--brass);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.timeline__handle:hover::after, .timeline__handle:focus-visible::after { background: var(--brass-bright); }

.timeline__playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--paper);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 3;
}

.timeline-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 6px 2px 0;
  font-variant-numeric: tabular-nums;
}

.transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.transport__time {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--paper-dim);
  min-width: 64px;
}
.transport__spacer { flex: 1; }

.time-input { font-variant-numeric: tabular-nums; }

.readout {
  padding: 12px 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--brass);
  font-weight: 500;
}

.sliders {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
}

.slider { display: block; }
.slider__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.slider output {
  font-size: 0.82rem;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 4px 0 0;
  accent-color: var(--brass);
  cursor: pointer;
}

.checks {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  padding: 18px 0;
  border-top: 1px solid var(--hairline-soft);
  border-bottom: 1px solid var(--hairline-soft);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.9rem;
  cursor: pointer;
}
.check input {
  margin: 2px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--brass);
  flex-shrink: 0;
}
.check small {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--paper-dim);
  line-height: 1.45;
}

.is-disabled { opacity: 0.4; }
.is-disabled, .is-disabled * { cursor: not-allowed; }

.field--format { max-width: 320px; }

.render-actions { margin-top: 4px; }
.render-actions__secondary {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 640px) {
  .sliders { grid-template-columns: 1fr; gap: 14px; }
  .options-grid--3 { grid-template-columns: 1fr 1fr; }
  .options-grid--3 > :last-child { grid-column: span 2; }
  .transport__spacer { display: none; }
}

@media (max-width: 480px) {
  body { padding: 40px 16px 64px; }
  .panel { padding: 20px; }
  .intake-row { flex-direction: column; align-items: stretch; }
  .options-grid { grid-template-columns: 1fr; }
  .main { padding-left: 16px; padding-right: 16px; }
  .panel--list { padding: 12px 14px; }
  .panel--list .library-filter { top: 8px; }
  .media-summary__thumb { width: 104px; }
  .item__thumb { width: 56px; }
  .item { align-items: flex-start; }
  .item__title, .item__meta { white-space: normal; }
  .item__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .item__actions .icon-btn { width: 32px; }
  .job__thumb { width: 52px; }
  .editor-head h1 { font-size: 1.4rem; }
}

/* ---------- Version PC, pied de page, prompt d'installation ---------- */

.app-foot {
  max-width: 720px;
  margin: 48px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  font-size: 0.8rem;
  color: var(--paper-dim);
}
.app-foot--small {
  margin-top: 14px;
  font-size: 0.74rem;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.app-foot a, .app-foot .btn-link {
  color: var(--paper-dim);
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: var(--hairline);
  text-underline-offset: 3px;
}
.app-foot a:hover, .app-foot .btn-link:hover { color: var(--paper); }

.prompt-dialog__text {
  width: 100%;
  margin-top: 14px;
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
}
.prompt-dialog .yt-dialog__foot a { color: var(--paper-dim); }

.quit-screen {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

/* Mise à jour de l'appli : l'avancement s'affiche par-dessus la page (pas de fenêtre d'installeur) */
.install-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--ink) 80%, transparent);
  backdrop-filter: blur(4px);
}
.install-box {
  width: min(440px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
}
.install-box h2 { margin: 0; font-size: 1.1rem; }
.install-box .progress { margin-top: 18px; }
.install-box .hint { margin: 10px 0 0; }
.install-box .btn { margin-top: 14px; }

/* ---------- Panneau de droite : listes plus serrées ---------- */

.item-day {
  margin: 18px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-dim);
  opacity: 0.75;
}
.item-day:first-child { margin-top: 0; }
.item-day + .item { box-shadow: none; }

.side .library-filter { top: 0; margin-bottom: 12px; }
.side .item { gap: 12px; padding: 9px 8px; }
.side .item__thumb { width: 56px; }
.side .item__title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.side .item__actions .icon-btn { width: 32px; height: 32px; }
.side .job { gap: 12px; }
.side .job__thumb { width: 56px; }
.side .empty { margin: 24px 4px; text-align: center; }
.side .selbar { bottom: 0; }

/* ---------- Style « Mon coffre » : en-tête, pastilles, teintes par type ---------- */

/* Teinte d'un type de média : fond léger + icône de la couleur du type */
.tint { --t: var(--brass); background: color-mix(in srgb, var(--t) 16%, transparent); color: var(--t); }
.tint--accent { --t: var(--brass); }
.tint--son { --t: var(--c-son); }
.tint--video { --t: var(--c-video); }
.tint--zip { --t: var(--c-zip); }
.tint--neutral { --t: var(--paper-dim); background: var(--surface); }

.brand__mark {
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--brass);
  color: var(--on-accent);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--brass) 70%, transparent);
}
.brand__mark .icon { width: 21px; height: 21px; }
.brand__name { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }

.btn--quiet {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--paper);
}
.btn--quiet:hover:not(:disabled) { border-color: var(--brass); }
.btn--quiet .icon { width: 15px; height: 15px; }

.hero {
  display: flex;
  align-items: center;
  gap: 20px;
}
.hero__ascii {
  flex: none;
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.12;
  color: var(--brass);
  white-space: pre;
  user-select: none;
}
.hero__title {
  font-family: 'Fraunces', serif;
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0;
}
.hero__hello { margin: 6px 0 0; color: var(--paper-dim); font-size: 0.98rem; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 28px;
}
.stats:empty { margin-bottom: 20px; }
.stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 7px 10px;
  border: 1px solid color-mix(in srgb, var(--t) 30%, transparent);
  border-radius: 999px;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
.stat b { color: var(--paper); font-weight: 600; }
.stat .icon { width: 15px; height: 15px; }
.tint--neutral.stat { border-color: var(--hairline); }

.ways__icon { width: 38px; height: 38px; border-radius: 10px; align-items: center; justify-content: center; }
.ways__icon .icon { width: 20px; height: 20px; }
.ways__btn .ways__icon.tint, .ways__btn.is-active .ways__icon.tint { color: var(--t); }
.ways__btn.is-active { background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--brass); border-color: var(--brass); }

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

.item__thumb.tint { border-color: transparent; }
.item__thumb.tint .icon { width: 20px; height: 20px; }
.side .item__thumb { width: 44px; aspect-ratio: 1; border-radius: 11px; }
.side .item__thumb:has(img) { width: 64px; aspect-ratio: 16 / 9; border-radius: 8px; }

.item__stored {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  color: var(--brass);
  font-weight: 600;
}
.item__stored .icon { width: 11px; height: 11px; }
.item.is-new { animation: stored 3s var(--ease) both; }
@keyframes stored {
  0%, 50% { background: color-mix(in srgb, var(--brass) 14%, transparent); }
  100% { background: transparent; }
}

.side__tabs .tab__icon .icon { width: 17px; height: 17px; }
.side__tabs .tab__badge { min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; font-size: 0.68rem; }

@media (max-width: 600px) {
  .hero { gap: 14px; }
  .hero__ascii { font-size: 10.5px; }
  .hero__title { font-size: 1.9rem; }
  .stats { gap: 6px; margin: 16px 0 20px; }
  .stat { padding: 5px 10px 5px 8px; font-size: 0.78rem; }
  .ways__icon { width: 34px; height: 34px; }
}

/* Retouches du 09/11 : coffre en bleu, stats en tableau, icônes des trois façons sans fond */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.stats:empty { display: none; }
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  padding: 12px 14px;
  border: none;
  border-radius: 0;
  font-size: 0.8rem;
}
.stat + .stat { border-left: 1px solid var(--hairline-soft); }
.stat .icon { width: 16px; height: 16px; grid-row: 1; }
.stat b { grid-row: 1; font-size: 1.25rem; font-weight: 700; color: var(--paper); line-height: 1.2; }
.stat__label { grid-column: 1 / -1; color: var(--t); font-weight: 500; }
.tint--neutral.stat { background: transparent; }
.tint--neutral .stat__label { color: var(--paper-dim); }

.ways__icon, .ways__icon.tint { background: none; width: auto; height: auto; }
.ways__btn .ways__icon.tint, .ways__btn.is-active .ways__icon.tint { color: var(--paper); }

@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 10px 12px; }
  .stat:nth-child(3n + 1) { border-left: none; }
  .stat:nth-child(n + 4) { border-top: 1px solid var(--hairline-soft); }
  .stat b { font-size: 1.1rem; }
}

/* ---------- Le coffre, en haut du panneau « Dans le coffre » : le dessin de l'icône,
   avec l'inventaire dedans. Reste visible quand on fait défiler la liste. ---------- */

.vault-dock {
  position: sticky;
  z-index: 3;
  top: -16px;
  margin: -16px -20px 14px;
  padding: 16px 20px 14px;
  background: var(--ink);
  border-bottom: 1px solid var(--hairline-soft);
}
.vault-dock .vault:has(.stats:empty) { display: none; }
.vault-dock:has(.stats:empty):has(.library-filter.hidden) { display: none; }
.vault-dock .library-filter { position: static; margin: 0; }
.vault-dock .vault + .library-filter { margin-top: 18px; }
.vault {
  position: relative;
  padding: 6px;
  border: 2.5px solid var(--brass);
  border-radius: 16px;
}
/* Pieds du coffre, comme sur l'icône */
.vault::before, .vault::after {
  content: "";
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 8px;
  border-radius: 0 0 2px 2px;
  background: var(--brass);
}
.vault::before { left: 22%; }
.vault::after { right: 22%; }
.vault__body {
  border: 2px solid var(--brass);
  border-radius: 9px;
  padding: 4px 14px;
  background: var(--surface);
}
/* Inventaire : le total en titre, puis des cases sur deux colonnes
   (chiffre au-dessus, mot en dessous) : rien ne passe à la ligne. */
.vault .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
  margin: 0;
  padding: 2px 0 6px;
  border: 0;
  background: none;
}
.vault .stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  padding: 7px 0 2px;
  border: 0;
  border-radius: 0;
  background: none;
}
.vault .stat + .stat { border-left: 0; }
.vault .stat .icon { display: none; }
.vault .stat b { font-size: 1rem; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.vault .stat__label {
  max-width: 100%;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--paper-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vault .stat--total {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0 9px;
  border-bottom: 1px dashed var(--hairline);
}
.vault .stat--total b { font-size: 1.35rem; font-weight: 700; }
.vault .stat--total .stat__label { font-size: 0.9rem; color: var(--paper); }
.hero { margin-bottom: 24px; }

@media (max-width: 960px) {
  .vault-dock { top: 0; margin: 0 0 14px; padding: 12px 0 18px; }
}

/* ---------- Fenêtre « Téléphone » (version PC) ---------- */

.phone-dialog__body { display: flex; gap: 20px; align-items: center; margin-top: 16px; }
.phone-dialog__qr {
  flex: none; width: 220px; height: 220px; border-radius: var(--radius-sm);
  background: #FFFFFF; display: grid; place-items: center; overflow: hidden;
}
.phone-dialog__qr img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.phone-dialog__qr .hint { color: #5E6876; text-align: center; padding: 12px; }
.phone-dialog__steps ol { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 0.9rem; }
.phone-dialog__steps li { margin-bottom: 6px; }
.phone-dialog__status { font-size: 0.88rem; margin: 12px 0 0; color: var(--paper-dim); }
.phone-dialog__status.is-ok { color: var(--teal); }
.phone-dialog__status.is-error { color: var(--danger); }
@media (max-width: 560px) {
  .phone-dialog__body { flex-direction: column; align-items: stretch; }
  .phone-dialog__qr { width: 100%; height: auto; aspect-ratio: 1; }
}

/* ---------- Fenêtre « Navigateur » : extension ajoutée sans store (version PC) ---------- */

.ext-firefox {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius-sm); font-size: 0.88rem;
}
.ext-firefox p { flex: 1 1 260px; margin: 0; line-height: 1.5; }
.ext-firefox .btn { margin-top: 0; width: auto; }
.ext-subtitle { margin: 16px 0 0; font-weight: 600; font-size: 0.9rem; }
.ext-steps { margin: 16px 0 12px; padding-left: 22px; line-height: 1.55; font-size: 0.9rem; }
.ext-steps li { margin-bottom: 10px; }
.ext-steps li > span:first-child { display: block; }
.ext-steps .btn { margin-top: 6px; width: auto; }
.ext-steps__path { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--teal); overflow-wrap: anywhere; }
.ext-steps__path.is-error { color: var(--danger); }
.ext-steps__copy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ext-steps__copy code {
  padding: 4px 8px; border-radius: 6px; background: var(--surface-raised);
  border: 1px solid var(--hairline); font-size: 0.85rem; user-select: all;
}
.ext-steps__copy .btn { margin-top: 0; }

/* ---------- Fenêtre « Réglages » (version PC) ---------- */

/* Groupes par sujet (Rangement, Qualité du son, Général, Mise à jour), chacun dans une carte.
   Une ligne = nom + petite explication à gauche, le réglage à droite. */
.settings-dialog { width: min(600px, calc(100vw - 32px)); }
.set-group { margin-top: 20px; }
.set-group__title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--paper-dim);
}
.set-group__title .icon { width: 16px; height: 16px; color: var(--brass); }
.set-group[hidden] { display: none; }
.set-card { border: 1px solid var(--hairline-soft); border-radius: var(--radius); background: var(--surface-raised); }
.set-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 16px;
  padding: 14px 16px;
}
.set-item + .set-item { border-top: 1px solid var(--hairline-soft); }
.set-item[hidden] { display: none; }
.set-item__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; cursor: default; }
label.set-item__text { cursor: pointer; }
.set-item__name { font-size: 0.93rem; font-weight: 500; color: var(--paper); }
.set-item__desc { font-size: 0.8rem; line-height: 1.45; color: var(--paper-dim); }
.set-item__desc[hidden] { display: none; }
.set-item__full { grid-column: 1 / -1; }
.set-item > .btn { width: auto; margin-top: 0; }
.set-select { width: auto; min-width: 180px; padding: 8px 36px 8px 12px; font-size: 0.88rem; }
.set-select--short { min-width: 140px; }
/* Interrupteur oui / non (case à cocher restylée) */
.set-switch {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 40px; height: 22px; border-radius: 999px; position: relative;
  background: var(--hairline); transition: background 0.15s ease;
}
.set-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s var(--ease);
}
.set-switch:checked { background: var(--brass); }
.set-switch:checked::after { transform: translateX(18px); }
.set-switch:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
/* « Comment ça marche ? » replié */
.set-more { font-size: 0.8rem; line-height: 1.5; color: var(--paper-dim); }
.set-more summary { cursor: pointer; color: var(--brass); width: fit-content; }
.set-more p { margin: 6px 0 0; }
.settings-path {
  display: block; padding: 8px 10px; border-radius: 6px; font-size: 0.85rem;
  background: var(--ink); border: 1px solid var(--hairline); overflow-wrap: anywhere;
}
.settings-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.settings-actions .btn { width: auto; margin-top: 0; }
.settings-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--paper-dim); cursor: pointer; }
.settings-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brass); }
.settings-check[hidden] { display: none; }
.settings-version { font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .set-item { grid-template-columns: 1fr; }
  .set-item > .set-switch { grid-row: 1; grid-column: 2; }
  .set-item:has(> .set-switch) { grid-template-columns: minmax(0, 1fr) auto; }
  .set-select { width: 100%; }
  .set-item > .btn { justify-self: start; }
  .settings-actions { justify-content: flex-start; }
}

/* Boutons de téléchargement de l'appli PC (fenêtre « Avoir MediaVior sur ton PC ») */
.dl-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.dl-buttons .btn.is-mine { background: var(--brass); color: var(--on-accent); border-color: var(--brass); }
.prompt-dialog .hint a { color: var(--brass); }
.prompt-dialog__alt { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--paper-dim); margin: 20px 0 0; }

/* ---------- Vitrine (page web seulement) : présentation et téléchargement ---------- */

.showcase { margin: -4px 0 28px; }
.showcase__lead { margin: 0; font-size: 1.12rem; line-height: 1.55; color: var(--paper); max-width: 60ch; }
.showcase__lead strong { color: var(--brass); font-weight: 600; }
.showcase__dl { margin-top: 18px; }
.showcase__dl .btn { margin-top: 0; }
.showcase__dl .btn .icon { width: 16px; height: 16px; }
.showcase__more { margin: 10px 0 0; font-size: 0.85rem; color: var(--paper-dim); }
.showcase__more a, .showcase__more .btn-link { color: var(--paper-dim); font-size: inherit; }
.showcase__grid {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.showcase__grid li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 2px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
}
.showcase__grid .tint {
  grid-row: span 2;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
}
.showcase__grid .tint .icon { width: 18px; height: 18px; }
.showcase__grid strong { font-size: 0.95rem; color: var(--paper); }
.showcase__grid small { font-size: 0.84rem; line-height: 1.45; color: var(--paper-dim); }
.showcase__try {
  display: flex; align-items: center; gap: 12px;
  margin: 30px 0 0;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--paper-dim);
}
.showcase__try::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

@media (max-width: 600px) {
  .showcase__lead { font-size: 1rem; }
  .showcase__grid { grid-template-columns: 1fr; }
  .showcase__dl .btn { flex: 1 1 100%; justify-content: center; }
}

/* Plusieurs liens : tout tient sans faire défiler (compteur à côté du titre, aide sur toute la largeur) */
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.field-head .field-label { margin-bottom: 0; }
.field-head .hint { margin: 0; }
#batch .option-hint { max-width: none; }

/* Aperçu (site public) : bandeau qui renvoie vers la vitrine */
.apercu-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  margin: -4px 0 24px; padding: 10px 14px;
  border: 1px solid var(--brass-dim); border-radius: var(--radius);
  background: color-mix(in srgb, var(--brass) 8%, transparent);
  font-size: 0.88rem; color: var(--paper);
}
.apercu-bar span { flex: 1 1 auto; }
.apercu-bar a { color: var(--brass); }
.apercu-bar .btn { margin-top: 0; }
.apercu-bar .btn .icon { width: 15px; height: 15px; }

/* Réglages : dossiers de musique lus par l'appli */
.settings-linked { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.settings-linked:empty { display: none; }
.settings-linked__row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.settings-linked__count { font-size: 0.82rem; opacity: 0.75; white-space: nowrap; }
.settings-linked__row .btn, .settings-linked__rescan { margin-top: 0; width: auto; justify-self: start; }
@media (max-width: 520px) {
  .settings-linked__row { grid-template-columns: 1fr auto; }
  .settings-linked__row .settings-path { grid-column: 1 / -1; }
}

/* Réglages : dossiers à part pour les sons et les vidéos */
.settings-error { color: var(--danger); opacity: 1; margin: 0; }
.settings-kinds { display: grid; gap: 8px; }
.settings-kinds[hidden] { display: none; }
.settings-kind { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.settings-kind__label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; }
.settings-kind__label .icon { width: 16px; height: 16px; }
.settings-kind .btn { margin-top: 0; width: auto; }
@media (max-width: 520px) {
  .settings-kind { grid-template-columns: 1fr auto; }
  .settings-kind .settings-path { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Barres de défilement au style de l'appli ----------
   Fine, arrondie, couleur des bordures ; bleue au survol. Chrome, Edge et la fenêtre de l'appli
   lisent ::-webkit-scrollbar ; Firefox lit scrollbar-color (sinon Chrome ignorerait le reste).
   Souris seulement : sur téléphone, la barre reste celle du système (fine, par-dessus). */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background-color: var(--hairline);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--brass-dim); }
  ::-webkit-scrollbar-thumb:active { background-color: var(--brass); }
  @supports not selector(::-webkit-scrollbar) {
    * { scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
  }
}

/* Ordinateur : la partie gauche défile seule, sa barre s'arrête au bord du coffre
   (avant, la barre de la fenêtre passait par-dessus le panneau de droite). */
@media (min-width: 961px) {
  body.shell .main {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
  /* Un peu moins d'espace : un lien analysé, en son, tient sans défiler sur un écran plein */
  body.shell .main { padding: max(18px, env(safe-area-inset-top)) 48px 12px; }
  .main .hero { margin-bottom: 14px; }
  .main .ways { margin-bottom: 14px; }
  .main .panel { padding: 24px; margin-bottom: 16px; }
  #result .media-summary { margin-bottom: 16px; padding-bottom: 16px; }
  #result .media-summary__text h2 { margin-bottom: 8px; }
  #result .mode-row { margin-bottom: 18px; }
  .main > .app-foot:not(.app-foot--small) { margin-top: 20px; }
  .main > .app-foot--small { margin-top: 8px; }
}
/* Un lien analysé : aide sur toute la largeur, liste des sites cachée (plus utile à ce moment-là) */
#result .option-hint { max-width: none; }
#intake:has(~ #result:not(.hidden)) .sites { display: none; }
/* Aide longue sous les formats : deux lignes, « Lire la suite » pour le reste */
.option-hint.is-clamped {
  position: relative;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* « Lire la suite » au bout de la 2e ligne, sur un fondu */
.hint-more {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 0 0 0 40px;
  line-height: inherit;
  font-size: inherit;
  color: var(--brass-bright);
  background: linear-gradient(90deg, transparent, var(--surface) 36px);
}
.hint-more[hidden] { display: none; }

/* ---------- Barre du haut dessinée par la page ----------
   - Windows : fenêtre de MediaVior (mediavior.py, native_window). La barre de Windows est
     enlevée ; la page dessine tout : coffre bleu, nom, et les boutons réduire / agrandir /
     fermer (mêmes symboles que Windows). Glisser la barre déplace la fenêtre (app-region).
   - Appli installée dans Edge/Chrome (« window-controls-overlay ») : même barre, mais les
     boutons de la fenêtre restent ceux du navigateur.
   local.js ajoute la classe own-titlebar à <body> dans ces deux cas. */
.titlebar { display: none; }

body.own-titlebar { --tb-h: 36px; }
body.own-titlebar.wco { --tb-h: env(titlebar-area-height, 33px); }
body.shell.own-titlebar { padding-top: var(--tb-h); }
body.own-titlebar .titlebar {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tb-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 0 calc(env(titlebar-area-x, 0px) + 14px);
  background: var(--ink);
  -webkit-app-region: drag;
  app-region: drag;
  user-select: none;
}
.titlebar__icon { display: inline-flex; color: var(--brass); }
.titlebar__icon svg { width: 17px; height: 17px; }
.titlebar__name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  color: var(--paper);
}
/* Boutons de la fenêtre (Windows seulement) : 46 px de large comme ceux de Windows */
.titlebar__ctl { display: none; margin-left: auto; height: 100%; -webkit-app-region: no-drag; app-region: no-drag; }
body.own-titlebar:not(.wco) .titlebar__ctl { display: flex; }
.titlebar__btn {
  width: 46px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--paper);
  font-family: 'Segoe Fluent Icons', 'Segoe MDL2 Assets', sans-serif;
  font-size: 10px;
  cursor: default;
}
.titlebar__btn:hover { background: color-mix(in srgb, var(--paper) 10%, transparent); }
.titlebar__btn:active { background: color-mix(in srgb, var(--paper) 16%, transparent); }
.titlebar__btn--close:hover { background: #C42B1C; color: #FFFFFF; }
.titlebar__btn--close:active { background: #B3271A; color: #FFFFFF; }
/* Bord du haut et coins du haut : on tire dessus pour redimensionner (fenêtre Windows) */
.titlebar__grip { display: none; }
body.native-window:not(.win-max) .titlebar__grip {
  display: block;
  position: absolute;
  z-index: 2;
  top: 0;
  left: 8px;
  right: 8px;
  height: 5px;
  cursor: ns-resize;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
body.native-window:not(.win-max) .titlebar__grip--left { left: 0; right: auto; width: 8px; height: 8px; cursor: nwse-resize; }
body.native-window:not(.win-max) .titlebar__grip--right { left: auto; right: 0; width: 8px; height: 8px; cursor: nesw-resize; }
body.own-titlebar .side { top: var(--tb-h); }
/* La partie gauche défile seule (voir plus haut) : elle s'arrête sous la barre */
@media (min-width: 961px) {
  body.own-titlebar.shell .main { height: calc(100vh - var(--tb-h)); height: calc(100dvh - var(--tb-h)); }
}
body.own-titlebar .side__tabs { padding-top: 20px; }

/* ---------- Infos du morceau (titre, interprètes, album…) ---------- */

.tags-dialog { width: min(620px, calc(100vw - 32px)); }
.tags-form { margin-top: 16px; }
.tags-top { display: flex; gap: 16px; align-items: stretch; }
.tags-cover {
  flex: none;
  align-self: flex-start;
  width: 132px;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-raised);
  display: grid;
  place-items: center;
  color: var(--paper-dim);
}
.tags-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tags-cover .icon { width: 36px; height: 36px; opacity: 0.6; }
.tags-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.tags-form input[type="text"] { width: 100%; }
.tags-form .field-label { margin-bottom: 6px; }
.tags-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.tags-grid__wide { grid-column: span 2; }
.tags-search { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--hairline-soft); }
.tags-search__title { margin: 0; font-size: 0.78rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--paper-dim); }
.tags-search .yt-dialog__search { margin-top: 10px; }
.tags-results { margin-top: 8px; max-height: 280px; overflow-y: auto; }
.tags-result__cover {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-raised);
  display: grid;
  place-items: center;
  color: var(--paper-dim);
}
.tags-result__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tags-result__cover .icon { width: 20px; height: 20px; }
.tags-dialog .yt-dialog__foot .btn--solid { width: auto; margin-top: 0; flex: none; }

/* Sons glissés depuis l'ordinateur sur le coffre */
#library.is-dropping { outline: 2px dashed var(--brass); outline-offset: -6px; border-radius: var(--radius); }

@media (max-width: 520px) {
  .tags-top { flex-direction: column; }
  .tags-cover { width: 96px; }
  .tags-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Sources avec abonnement (Réglages) et fenêtre d'avertissement */
.field[hidden] { display: none; }
#settingsStreamripForm .field { margin-top: 8px; }
#settingsStreamripForm .settings-actions { margin-top: 10px; }
.risk-dialog { width: min(520px, calc(100vw - 32px)); }
.risk-dialog .settings-check { margin: 8px 0 4px; color: var(--paper); }
.risk-dialog .yt-dialog__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.risk-dialog .yt-dialog__foot .btn { width: auto; margin-top: 0; }

/* Sources avec abonnement : pastilles « branché » (Réglages) et ligne sous la case du lien */
.svc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 0.78rem; line-height: 1.4; color: var(--paper-dim);
  background: var(--ink); border: 1px solid var(--hairline-soft);
}
.svc-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.svc-chip__name { font-weight: 600; color: var(--paper); }
.svc-chip.is-on { border-color: color-mix(in srgb, var(--teal) 45%, transparent); background: color-mix(in srgb, var(--teal) 10%, transparent); }
.svc-chip.is-on .svc-chip__dot { background: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
.svc-chip.is-on .svc-chip__state { color: var(--teal); }
.subs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding: 0;
  background: none; border: 0; font: inherit; color: var(--paper-dim); font-size: 0.8rem; cursor: pointer; text-align: left;
}
.subs.hidden { display: none; }
.subs:hover .svc-chip.is-on { border-color: var(--teal); }
.subs:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 6px; }
#intake:has(~ #result:not(.hidden)) .subs { display: none; }
/* Mode d'emploi du jeton Deezer / cookie Spotify */
.token-help { margin-top: 10px; }
.token-help ol { margin: 6px 0 0; padding-left: 20px; }
.token-help li { margin: 3px 0; }
.token-help a { color: var(--brass); }
/* Mise à jour : un seul bouton à la même place, la boîte garde sa taille */
.update-actions { flex-wrap: nowrap; }
.update-actions .btn { white-space: nowrap; }

/* Liste de titres : morceau choisi à la main, bien visible */
.sons-list__pick { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.sons-list__picked {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 5px; border-radius: 999px;
  font-weight: 600; color: var(--teal); background: color-mix(in srgb, var(--teal) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
}
.sons-list__picked .icon { width: 12px; height: 12px; } /* la coche, centrée dans la pastille */
.sons-list__pick-title { color: var(--paper-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sons-list__item.is-picked { box-shadow: inset 3px 0 0 var(--teal); }
/* Fenêtre de choix : source (YouTube / Deezer / Qobuz), morceau déjà choisi, extrait audio */
.ways-mini { display: inline-flex; gap: 4px; padding: 3px; margin-top: 12px; border-radius: 999px; background: var(--ink); border: 1px solid var(--hairline-soft); }
.ways-mini.hidden { display: none; }
.ways-mini__btn { padding: 4px 14px; border: 0; border-radius: 999px; background: none; color: var(--paper-dim); font: inherit; font-size: 0.82rem; cursor: pointer; }
.ways-mini__btn.is-active { background: var(--brass); color: var(--on-accent); }
.yt-results__item.is-chosen { box-shadow: inset 3px 0 0 var(--teal); background: color-mix(in srgb, var(--teal) 8%, transparent); }
.yt-dialog__player:has(audio) { aspect-ratio: auto; background: none; }
.yt-dialog__player audio { width: 100%; display: block; }
a.yt-results__preview { display: grid; place-items: center; color: var(--paper-dim); }
/* Avec « Chercher sur » : les deux choix côte à côte, le bouton en dessous sur toute la largeur */
.sons-actions:has(#sonsSourceField:not(.hidden)) { flex-wrap: wrap; }
.sons-actions:has(#sonsSourceField:not(.hidden)) .field { flex: 1 1 200px; }
.sons-actions:has(#sonsSourceField:not(.hidden)) .btn { flex: 1 1 100%; }
