/* =====================================================================
   Coffre Velora (public/coffre.js) — 08/11/2026
   Grille de médias (page Médias et fenêtre de choix), aperçu plein écran, barre des envois.
   Téléphone : fenêtre plein écran (hauteur dynamique 100dvh), zones sûres (encoche, barre du bas), cibles de 44 px.
   ===================================================================== */
.vv { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.vv .grow, .vv-tray .grow, .vv-sh .grow, .vv-pv .grow { flex: 1; }
.vv-bar1, .vv-bar2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.vv-bar1 { flex-wrap: nowrap; }
.vv-q { flex: 1 1 200px; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--surface-2, var(--surface)); color: var(--fg); font: inherit; font-size: 14px; }
.vv-q:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.vv-sort, .vv-alb { height: 38px; max-width: 100%; }
.vv-imp { display: inline-flex; align-items: center; gap: 6px; height: 38px; white-space: nowrap; }
.vv-imp .i { width: 16px; height: 16px; }
.vv-kinds { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.vv-kinds button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.vv-kinds button em { font-style: normal; opacity: .7; margin-left: 2px; font-size: 12px; }
.vv-kinds button[aria-pressed="true"] { background: var(--surface-3); color: var(--fg); border-color: color-mix(in srgb, var(--fg) 18%, var(--line)); }
.vv-err { margin: 0; padding: 10px 12px; border-radius: var(--r-md, 10px); background: color-mix(in srgb, #e5484d 12%, transparent); color: var(--fg); font-size: 13px; }
.vv-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--muted); }
.vv-empty .i { width: 28px; height: 28px; opacity: .6; }
.vv-empty b { color: var(--fg); font-size: 15px; }
.vv-empty p { margin: 0; max-width: 440px; font-size: 13px; }

.vv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.vv-tile { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--surface); overflow: hidden; cursor: pointer; transition: border-color var(--dur, .16s), transform var(--dur, .16s); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.vv-tile:hover { border-color: color-mix(in srgb, var(--fg) 20%, var(--line)); }
.vv-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vv-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.vv-tile.off { opacity: .35; cursor: not-allowed; }
.vv-th { display: grid; place-items: center; aspect-ratio: 1; background: var(--surface-3); overflow: hidden; }
.vv-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vv-th > i .i { width: 26px; height: 26px; color: var(--muted); }
.vv-tile.sk .vv-th { animation: vvPulse 1.2s ease-in-out infinite; }
@keyframes vvPulse { 50% { opacity: .55; } }
.vv-badges { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; pointer-events: none; }
.vv-badges em { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .62); color: #fff; font-style: normal; font-size: 11px; font-weight: 600; }
.vv-badges .i { width: 12px; height: 12px; }
.vv-ck { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.vv-ck::before { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .9); background: rgba(0, 0, 0, .3); box-sizing: border-box; grid-area: 1 / 1; }
.vv-ck b { grid-area: 1 / 1; z-index: 1; color: #fff; font-size: 12px; }
.vv-tile.on .vv-ck::before { background: var(--accent); border-color: var(--accent); }
.vv-cap { display: flex; flex-direction: column; gap: 1px; padding: 7px 9px 8px; min-width: 0; }
.vv-cap b { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.vv-cap small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vv-more { align-self: center; min-height: 40px; }
.vv-selbar { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: var(--r-lg, 12px); background: var(--surface-2, var(--surface)); box-shadow: var(--shadow-md); }
.vv-selbar .danger, .vv-pv .danger { color: #e5484d; }

/* la page */
.vv-page .vv-who { margin: 0 0 12px; }
.vv-page .vv-who label { display: inline-flex; align-items: center; gap: 8px; }
.vv-page .vv-who select { width: auto; min-width: 180px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--surface-2, var(--surface)); color: var(--fg); font: inherit; font-size: 14px; }
.vv-accs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.vv-acc { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--surface); color: var(--fg); font: inherit; cursor: pointer; text-align: left; }
.vv-acc:hover { border-color: color-mix(in srgb, var(--fg) 20%, var(--line)); }

/* la fenêtre de choix */
html.vv-lock, html.vv-lock body { overflow: hidden; }
.vv-modal { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .55); animation: vvFade .14s ease-out; }
@keyframes vvFade { from { opacity: 0; } }
.vv-sheet { display: flex; flex-direction: column; width: min(980px, 100%); height: min(760px, 100%); border: 1px solid var(--line); border-radius: 14px; background: var(--bg); box-shadow: var(--shadow-lg); overflow: hidden; }
.vv-sh { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.vv-sh > div { display: flex; flex-direction: column; min-width: 0; }
.vv-sh b { font-size: 15px; }
.vv-sh small { font-size: 12px; color: var(--muted); }
.vv-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 0; overscroll-behavior: contain; }
.vv-body .vv-selbar { position: sticky; bottom: 0; margin: 4px -14px 0; border-radius: 0; border-width: 1px 0 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.vv-ico { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.vv-ico:hover { background: var(--surface-3); color: var(--fg); }
.vv-ico .i { width: 18px; height: 18px; }

/* aperçu plein écran */
.vv-pv { position: fixed; inset: 0; z-index: 1300; display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr); background: rgba(8, 8, 10, .96); color: #ececea; }
.vv-pv-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
.vv-pv-top b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vv-pv .vv-ico { color: #ccc; }
.vv-pv-media { display: grid; place-items: center; min-height: 0; padding: 8px 56px 16px; }
.vv-pv-media img, .vv-pv-media video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.vv-pv-media audio { width: min(420px, 100%); }
.vv-sk-big { width: 60%; aspect-ratio: 4 / 3; border-radius: 8px; background: #222; animation: vvPulse 1.2s ease-in-out infinite; }
.vv-pv-side { overflow: auto; padding: 4px 16px 20px; border-left: 1px solid #25262b; font-size: 13px; }
.vv-pv-side dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 12px; }
.vv-pv-side dt { color: #8b8b90; }
.vv-pv-side dd { margin: 0; overflow-wrap: anywhere; }
.vv-pv-side h4 { margin: 14px 0 6px; font-size: 13px; }
.vv-pv-side ul { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.vv-pv-side li small { display: block; color: #8b8b90; }
.vv-pv-side .muted { color: #8b8b90; }
.vv-pv-act { display: flex; gap: 6px; flex-wrap: wrap; }
.vv-nav { position: absolute; top: 50%; width: 44px; height: 64px; margin-top: -32px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; font-size: 30px; cursor: pointer; }
.vv-nav.prev { left: 8px; }
.vv-nav.next { right: 308px; }

/* la barre des envois */
.vv-tray { position: fixed; right: 16px; bottom: 16px; z-index: 1250; width: min(380px, calc(100vw - 32px)); max-height: min(420px, 60dvh); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2, var(--surface)); box-shadow: var(--shadow-lg); overflow: hidden; font-size: 13px; }
body.vv-selon .vv-tray, html.vv-lock .vv-tray { bottom: 84px; }
.vv-tray header { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line); }
.vv-tray header b { font-size: 13px; font-weight: 600; }
.vv-tray header .vv-ico .i { transition: transform .15s; transform: rotate(90deg); }
.vv-tray.min header .vv-ico .i { transform: rotate(-90deg); }
.vv-tray.min ul { display: none; }
.vv-tray.min header { border-bottom: 0; }
.vv-tray ul { list-style: none; margin: 0; padding: 4px 0; overflow: auto; }
.vv-job { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; }
.vv-jt { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.vv-jt img { width: 100%; height: 100%; object-fit: cover; }
.vv-jt .i { width: 16px; height: 16px; color: var(--muted); }
.vv-jm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.vv-jm b { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vv-jm small { color: var(--muted); font-size: 12px; }
.vv-job.error .vv-jm small { color: #e5484d; }
.vv-bar { display: block; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.vv-bar > i { display: block; height: 100%; background: var(--accent); transition: width .2s linear; }
.vv-job.retrying .vv-bar > i { background: #e5a50a; }
.vv-ok .i { width: 18px; height: 18px; color: #30a46c; }
.vv-tbtn { flex: none; min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--fg); font: inherit; font-size: 12.5px; cursor: pointer; }

/* téléphone et petites fenêtres */
@media (max-width: 720px) {
  .vv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .vv-tile { border-radius: 6px; }
  .vv-cap { display: none; }
  .vv-badges { left: 4px; top: auto; bottom: 4px; }
  .vv-q { flex: 1 1 auto; height: 44px; font-size: 16px; }
  .vv-sort, .vv-alb { height: 44px; flex: 1 1 0; min-width: 0; font-size: 16px; padding-right: 30px; text-overflow: ellipsis; }
  .vv-bar2 { flex-wrap: nowrap; }
  .vv-bar2 .btn-ghost { flex: none; min-height: 44px; }
  .vv-imp { flex: none; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .vv-imp span { display: none; }
  .vv-page .vv-who select { min-height: 44px; font-size: 16px; }
  .vv-kinds { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .vv-kinds button { height: 36px; flex: none; }
  .vv-selbar button { min-height: 44px; }
  .vv-modal { padding: 0; place-items: stretch; }
  .vv-sheet { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .vv-sh { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); }
  .vv-body { padding: 10px max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); }
  .vv-body .vv-selbar { margin: 4px -10px 0; }
  .vv-pv { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; }
  .vv-pv-media { padding: 4px 4px 8px; }
  .vv-pv-side { max-height: 34dvh; border-left: 0; border-top: 1px solid #25262b; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .vv-nav { display: none; }
  .vv-tray { left: 8px; right: 8px; width: auto; bottom: max(8px, env(safe-area-inset-bottom)); }
  body.vv-selon .vv-tray, html.vv-lock .vv-tray { bottom: calc(76px + env(safe-area-inset-bottom)); }
  html body .vv .vv-q, html body .vv .vv-imp, html body .vv .vv-sort, html body .vv .vv-alb { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .vv-modal, .vv-tile.sk .vv-th, .vv-sk-big { animation: none; } }
