/* Médiathèque : grille, import, fenêtre d'un média (maquettes/medias-mediatheque.html). */
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); display: flex; flex-direction: column; min-width: 0; transition: border-color 0.12s; }
.media-card:hover { border-color: var(--border-strong); }
.media-open { display: block; color: inherit; text-decoration: none; border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; overflow: hidden; }
.media-open:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.media-thumb { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
.media-name { padding: 10px 12px 0; font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { padding: 4px 12px 12px; font-size: 12px; color: var(--text-2); }
.media-usage { display: flex; padding: 0 12px 12px; margin-top: -4px; }
.import-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.import-results li { display: flex; justify-content: space-between; gap: 12px; }
.import-results .file { overflow-wrap: anywhere; min-width: 0; }
.import-results .ko { color: var(--danger-text); white-space: nowrap; }
.import-results .ok { color: var(--ok-text); white-space: nowrap; }

.thumb-wrap { position: relative; display: block; }
.play-badge { position: absolute; left: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; display: grid; place-items: center; }
.play-badge .i { fill: currentColor; }
.dur-badge { position: absolute; right: 8px; bottom: 8px; padding: 1px 6px; border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 11px; font-family: "JetBrains Mono", ui-monospace, monospace; }
.media-busy { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; padding: 12px; }
.media-busy .busy-label { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; max-width: 220px; font-size: 12px; color: var(--text-2); text-align: center; }
.media-busy .progress { width: 100%; }
.media-busy .progress > span { background: var(--warn); }
.media-busy.failed { background: var(--danger-bg); }
.media-busy.failed .busy-label { flex-direction: row; justify-content: center; color: var(--danger-text); font-weight: 500; }
.preview-stage.media-busy { aspect-ratio: 16 / 9; }
.preview-stage.media-busy .busy-label { max-width: 360px; font-size: 14px; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.upload-progress .row { display: flex; justify-content: space-between; }

@media (max-width: 720px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
.video-stage { position: relative; }
.video-controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.65)); color: #fff; font-size: 12px; font-family: "JetBrains Mono", ui-monospace, monospace; }
.video-controls button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; }
.video-controls button:hover { background: rgba(255, 255, 255, 0.15); }
.video-controls button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.video-controls svg { width: 14px; height: 14px; fill: currentColor; }
.video-controls .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); position: relative; cursor: pointer; }
.video-controls .bar span { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #fff; border-radius: 2px; }

/* Visionneuse (maquettes/medias-visionneuse-retouche.html, validée le 2026-12-02). */
.viewer { max-height: calc(100vh - 64px); }
.viewer .modal-split-media { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.viewer .modal-body { overflow-y: auto; min-height: 0; }
.viewer .modal-head { justify-content: flex-start; gap: 8px; }
.viewer .modal-head h2 { margin-right: auto; }
.viewer-count { font-size: 13px; color: var(--text-2); font-family: "JetBrains Mono", ui-monospace, monospace; white-space: nowrap; }
.viewer .preview { min-height: 0; justify-content: space-between; gap: 16px; }
.viewer-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 12px; }
.viewer-stage { width: min(calc(100% - 112px), max(280px, (100vh - 330px) * 16 / 9)); }
.viewer-stage.is-portrait { width: min(calc(100% - 112px), max(160px, (100vh - 330px) * 9 / 16)); }
.viewer-arrow { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow-float); text-decoration: none; }
.viewer-arrow:hover { background: var(--hover); }
.viewer-arrow:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.viewer-arrow[data-off] { opacity: 0.3; box-shadow: none; }
.viewer-arrow .i { width: 22px; height: 22px; }
.viewer-strip { display: flex; gap: 8px; justify-content: center; overflow-x: auto; padding: 4px 2px 2px; flex: none; }
.strip-item { position: relative; flex: none; width: 76px; aspect-ratio: 16 / 10; border: 2px solid transparent; border-radius: var(--r-sm); overflow: hidden; background: var(--surface); opacity: 0.6; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-item:hover, .strip-item:focus-visible { opacity: 1; }
.strip-item[aria-current="true"] { border-color: var(--brand); opacity: 1; }
.strip-play { position: absolute; left: 4px; bottom: 4px; width: 16px; height: 16px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; display: grid; place-items: center; }
.strip-play .i { width: 9px; height: 9px; fill: currentColor; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.viewer-name { margin: 0; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.hint-line { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); margin: 0; }
.hint-line .i { flex: none; margin-top: 2px; }
.kbd-hint { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }
.kbd-hint.alone { margin-right: auto; }
kbd { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--surface); color: var(--text-2); }
.viewer-main:fullscreen { background: #000; padding: 16px; }
.viewer-main:fullscreen .viewer-stage { width: calc(100vw - 160px); height: calc(100vh - 32px); aspect-ratio: auto; border-radius: 0; }

/* Retouche d'une image. */
.head-back { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.head-back .icon-btn { width: var(--h); height: var(--h); flex: none; }
.editor-error { margin: 16px 24px 0; }
.editor-tools { gap: 0; padding: 8px 24px; }
.editor-tools section { padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.editor-tools section + section { border-top: 1px solid var(--border); }
.editor-tools h4 { margin: 0; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.ratio-chips { border: 0; padding: 0; margin: 0; }
.ratio-chips .chip { cursor: pointer; }
.ratio-chips .chip:has(input:checked) { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.ratio-chips .chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool-row { display: flex; gap: 8px; }
.tool-row[hidden], .hint-line[hidden], .btn[hidden], .icon-btn[hidden], .editor-stage img[hidden], .editor-stage canvas[hidden] { display: none; }
.btn-icon { width: var(--h); padding: 0; justify-content: center; }
.btn-icon[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.slider { gap: 6px; }
.slider .row { display: flex; justify-content: space-between; align-items: center; }
.slider label { font-size: 13px; color: var(--text-2); }
.range-val { font-size: 12px; font-family: "JetBrains Mono", ui-monospace, monospace; color: var(--text); }
.slider .range { width: 100%; margin: 0; accent-color: var(--primary); }
.editor .preview { justify-content: center; gap: 14px; }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.editor-stage { touch-action: none; user-select: none; }
.editor-stage canvas { display: block; width: 100%; height: 100%; }
.editor-stage.is-live { aspect-ratio: var(--ar); width: min(100%, max(220px, (100vh - 330px) * var(--ar-n))); }
.editor-note { text-align: center; font-size: 13px; margin: 0; }
.crop-box { position: absolute; outline: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); cursor: move; }
.crop-box .thirds { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(90deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) 0 calc(33.33% + 0.5px), transparent 0 calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) 0 calc(66.66% + 0.5px), transparent 0),
  linear-gradient(180deg, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) 0 calc(33.33% + 0.5px), transparent 0 calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) 0 calc(66.66% + 0.5px), transparent 0); }
.crop-box .h { position: absolute; width: 22px; height: 22px; border: 4px solid #fff; }
.crop-box .tl { left: -4px; top: -4px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.crop-box .tr { right: -4px; top: -4px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.crop-box .bl { left: -4px; bottom: -4px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.crop-box .br { right: -4px; bottom: -4px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.editor-stage.showing-original .crop-box { display: none; }

@media (max-width: 720px) {
  .viewer { max-height: none; }
  .viewer-stage, .viewer-stage.is-portrait { width: calc(100% - 96px); }
  .viewer-arrow { width: 36px; height: 36px; }
  .kbd-hint { display: none; }
  .viewer .preview { order: -1; }
}
